我有一个使用 mopub 进行广告的项目。它设置为使用 Google AdMob 和 Millennial Media 第三方广告。我已按照以下位置的说明进行操作:
http://help.mopub.com/customer/portal/articles/1049608-simple-ads-demo---android-2-4-integrating
并且当我从eclipse运行它时,能够在设备(nexus 7)上运行应用程序时显示广告。但是,如果我导出应用程序并将 apk 安装到设备上,则广告不起作用。来自设备的 logcat 给出以下错误:
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...
似乎这些库没有被导出到 apk 中。根据:
http://tools.android.com/recent/dealingwithdependenciesinandroidprojects
lib 目录中的 jar 文件应该会自动导出到应用程序中。我已将库放在 mopub 项目和我的项目中。我还尝试将库添加到构建路径并确保选中导出复选框。一切都无济于事。
我已经尝试将应用程序与 mopub 项目断开连接,只添加已编译的 mopub 库并将其粘贴到我的应用程序的 lib 目录中,但是当我导出项目时 proguard 会出错。
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)
同样,当我从 eclipse 运行它时它可以在设备上运行,但当我从 apk 安装它后运行它时它不能运行。
任何帮助将不胜感激。谢谢!