Mopub ads not showing

六月ゝ 毕业季﹏ 提交于 2019-11-26 12:47:29

问题


I\'ve been stuck on an issue for a while and I can\'t figure out what it is. The thing is I recently updated the Mopub Android SDK and both interstitial + banner ads (AdMob and Millennial Media) were working fine before that. Now these ads aren\'t working in the release build but they do work in debug build. So I think this is an issue with proguard but I can\'t trace what it is. The proguard is setup according to Mopub guidelines.

I have added the following to proguard for my project:

-keep class com.google.ads.**
-keep class com.millennialmedia.android.**
-keep public class com.mopub.mobileads.*
-keepclassmembers class com.millennialmedia.android.* {
public *;
}

In the release build, when I try to display an ad I get the following logs :

I/MoPub   (29856): Fetching ad network type: admob_native
D/MoPub   (29856): Loading custom event interstitial adapter.
D/MoPub   (29856): Attempting to invoke custom event: com.mopub.mobileads.GoogleAdMobInterstitial
D/MoPub   (29856): Couldn\'t locate or instantiate custom event: com.mopub.mobileads.GoogleAdMobInterstitial.

I/MoPub   (29856): Fetching ad network type: admob_native
D/MoPub   (29856): Loading custom event adapter.
D/MoPub   (29856): Attempting to invoke custom event: com.mopub.mobileads.GoogleAdMobBanner
D/MoPub   (29856): Couldn\'t locate or instantiate custom event: com.mopub.mobileads.GoogleAdMobBanner.
V/MoPub   (29856): MoPubErrorCode: Unable to find Native Network or Custom Event adapter.

Please suggest what the error might be. Any feedback would be appreciated.

Also I don\'t know if this is relevant or not but I\'m working on a Cocos2dx Android project.

Thanks.


回答1:


It is ProGuard indeed. If you don't want it to "get rid" of Mopub, AdMob and MMedia code entirely, just put the following lines into proguard-project.txt file of your project:

    -keep class com.google.ads.** {*;}
    -keep class com.mopub.mobileads.** {*;}
    -keep class com.millennialmedia.android.** {*;}
    -keep class com.millennialmedia.google.** {*;}



回答2:


You need to create a custom native network and add your custom class in mopub site. Same with millennial and make sure you added necessary adaptors in your project.



来源:https://stackoverflow.com/questions/18591724/mopub-ads-not-showing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!