0

I have a project that is using mopub for ads. It is setup to use the Google AdMob and Millennial Media third party ads. I've followed the instructions found at:

http://help.mopub.com/customer/portal/articles/1049608-simple-ads-demo---android-2-4-integrating

and have been able to get the ads to display when running the app on the device (nexus 7) when I run it from eclipse. However, if I export the app and install the apk onto the device the ads don't work. logcat from the device gives the following errors:

I/MoPub   (30361): Fetching ad network type: millennial_native
I/MoPub   (30361): Loading native ad
D/MoPub   (30361): Couldn't find com.mopub.mobileads.MillennialAdapter class. Make sure the project includes the adapter library for com.mopub.mobileads.MillennialAdapter from the extras folder
I/MoPub   (30361): Couldn't load native adapter. Trying next ad...
...
I/MoPub   (30361): Fetching ad network type: admob_native
I/MoPub   (30361): Loading native ad
D/MoPub   (30361): Couldn't find com.mopub.mobileads.GoogleAdMobAdapter class. Make sure the project includes the adapter library for com.mopub.mobileads.GoogleAdMobAdapter from the extras folder
I/MoPub   (30361): Couldn't load native adapter. Trying next ad...

It seems that the libraries aren't being exported into the apk. According to:

http://tools.android.com/recent/dealingwithdependenciesinandroidprojects

jar files in the lib directory should be exported into the app automatically. I've placed the libraries in both the mopub project and my project. I've also played with adding the libraries to the Build Path and making sure that the export check box is checked. All to no avail.

I've tried disconnecting the app from the mopub project and just adding the compiled mopub library and sticking it in my app's lib directory but then proguard gives errors when I export the project.

Proguard returned with error code 1. See console
Warning: com.mopub.mobileads.MraidView: can't find referenced class com.mopub.mobileads.R
   You should check if you need to specify additional program jars.
Warning: there were 41 unresolved references to classes or interfaces.
      You may need to specify additional library jars (using '-libraryjars').
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)

Again, it works on the device when I run it from eclipse but not when I run it after installing it from the apk.

Any help would be greatly appreciated. Thanks!

gaijin
  • 185
  • 1
  • 10
  • 1
    It's because of ProGuard obfuscating your code. Look [here](http://stackoverflow.com/questions/18591724/mopub-ads-not-showing/21923636#21923636). – Onik Feb 27 '14 at 01:24

2 Answers2

1

Everything is fine that you added native Millennial and Admob SDK's in libs folder. The problem is that Adapter classes are not found (which are not in mmedia or admob jars, they're custom mopub classes). They are in mopub SDK's extras\src\com\mopub\mobileads\networkadapters folder. Copy them to your projects com.mopub.mobileads package as it is suggested in your given mopub tutorial.

Adomas
  • 466
  • 1
  • 8
  • 21
  • Thanks for the reply. I had previously done that as well. If I remove them from the project and build, the ads don't work in the app when running from eclipse. If I add them it does work when running from eclipse but not from an apk. At first I was unsure when this [page](https://github.com/mopub/mopub-client/wiki/IntegrationHowToThirdPartyAndroid) said to copy the adapters into "com.mopub.mobileads in your src/". The tutorial says to copy them to the mopub project. I've tried both the mopub and project and the app's project and get the same behavior. – gaijin Apr 14 '13 at 04:42
  • Maybe mopub project is not exported your .apk. Check project properties -> java build path -> order of export. Move mopub library above your project. – Adomas Apr 19 '13 at 11:57
  • @gaijin could you take a look at my question here please: http://stackoverflow.com/questions/32491486/adding-admob-adaptor-to-mopub as you seem to know about MoPub - specifically I'm having trouble understanding the part about copying the 2 files mentioned to '"com.mopub.mobilead"' in *your project*. I don't have any '"com.mopub.mobilead"' in my project - so a little confused (actually, a lot) - any help would be appreciated, cheers. – Zippy Sep 12 '15 at 19:58
0

This is late and old but I found in another project later that proguard was removing the libraries. Finding the right -keep's fixed it.

gaijin
  • 185
  • 1
  • 10