MoPub Ad load fails if app is obfuscated


#1

In my android app I am using MoPub to mediate ads from Google’s AdMob. Everything works fine when the app is not obfuscated. However, once the app is obfuscated, the ad fails to load.

My proguard file is updated with proguard file from Android sample project from MoPub. Please let me know how can I get ads working even if the app is obfuscated.


#2

Hi!

Can you show your Proguard rules?
Also, can you try the below?

#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#public *;
#}

-keep class com.flurry.** { ; }
-dontwarn com.flurry.
*
-keepattributes Annotation,EnclosingMethod,Signature
-keepclasseswithmembers class * {
public (android.content.Context, android.util.AttributeSet, int);
}

Google Play Services library

-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}

Keep public classes and methods.

-keepclassmembers class com.mopub.** { public ; }
-keep public class com.mopub.
*
-keep public class android.webkit.JavascriptInterface {}

Explicitly keep any custom event classes in any package.

-keep class * extends com.mopub.mobileads.CustomEventBanner {}
-keep class * extends com.mopub.mobileads.CustomEventInterstitial {}
-keep class * extends com.mopub.nativeads.CustomEventNative {}
-keep class * extends com.mopub.nativeads.CustomEventRewardedAd {}

Keep methods that are accessed via reflection

-keepclassmembers class ** { @com.mopub.common.util.ReflectionTarget *; }

-keepnames @com.google.android.gms.common.annotation.KeepName class *

-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}

#If you are using the Google Mobile Ads SDK, add the following:

Preserve GMS ads classes

-keep class com.google.android.gms.ads.** { ;
}
-dontwarn com.google.android.gms.ads.
*

Support for Android Advertiser ID.

-keep class com.google.android.gms.common.GooglePlayServicesUtil {;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {*;}

#If you are using the Millennial Media SDK, add the following:

Preserve Millennial Ads classes

-keep class com.millennialmedia.** { ;
}
-dontwarn com.millennialmedia.
*
-keep class com.tapjoy.** { ; }
-keep class com.moat.
* { *; }

-keepattributes JavascriptInterface
-keepattributes Annotation
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName ;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
-keep class com.google.android.gms.ads.identifier.
* { ; }
-dontwarn com.tapjoy.
*
-dontwarn java.lang.invoke.*
-dontwarn okio.**
-dontwarn retrofit2.*
-dontwarn com.millennialmedia.android
-dontwarn com.inmobi.**
-dontwarn com.millennialmedia.**
-dontwarn com.flurry.android.ads.sdk**