Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

admob ads are not shown with pro guard

I developed android app and I used admob sdk 6.2.1 for showing ads, and when I tested the app on my real device and on the emulator,ads are shown. but when I apply pro guard to my app and test it on my device(I tested it on another devices also) ads are not shown up, any help please!

like image 562
Dany Wehbe Avatar asked Nov 12 '12 13:11

Dany Wehbe


People also ask

Why my ads are not showing on AdMob?

Ads won't show if you haven't integrated the Google Mobile Ads SDK correctly. Is your ad implementation code working properly? Test your implementation code to check that ads can show. You can also use ad inspector to test your app's ad serving.

How long does it take for AdMob to show ads?

Ad serving When apps are newly registered with AdMob, it typically takes up to an hour and a few ad requests to allow inventory to build. Because of this, you may not see live impressions immediately. Note: In some cases, it may take longer than an hour. Please wait 24 hours before seeking additional help.

Can I use AdMob in VPN app?

Yes you can still use AdMob ads in your VPN application.


3 Answers

Add this to your proguard:

-keep class com.google.ads.** # Don't proguard AdMob classes
-dontwarn com.google.ads.** # Temporary workaround for v6.2.1. It gives a warning that you can ignore

EDIT 2020:

For some time now, the Google Mobile Ads SDK has distributed its own proguard rules that get manifest merged into your app, so you don't need to add anything yourselves. The merged rules also keep around methods from third-party mediation adapters that are needed to make mediation work.

like image 181
Eric Leichtenschlag Avatar answered Sep 30 '22 04:09

Eric Leichtenschlag


From the docs:

To safely use ProGuard with Google Mobile Ads, add the following to your ProGuard config:

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

-keep public class com.google.ads.** {
    public *;
}

This will prevent all public methods on public classes from being obfuscated.

If you use AdMob Mediation with other ad networks, you should keep public methods from public classes for each SDK and adapter library as well.

like image 37
cprcrack Avatar answered Sep 30 '22 05:09

cprcrack


Proguard Rules for Admob in Android

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

# For old ads classes
-keep public class com.google.ads.**{
   public *;
}

# For mediation
-keepattributes *Annotation*

# Other required classes for Google Play Services
# Read more at http://developer.android.com/google/play-services/setup.html
-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;
}
like image 26
Bhavik Nathani Avatar answered Sep 30 '22 05:09

Bhavik Nathani