Search code examples
androideclipsejarmopub

app using mopub can't find library when running on android device


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!


Solution

  • 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.