1

I am integrating Unity admob in my unity game which is build in Unity 2018.1.1f1 and i am using following.

  • Unity 2018.1.1f1
  • Admob plugin v 3.15.1
  • JDK 8
  • SDK Lollipop
  • Google play services [latest]

and getting the following error in logcat. while i have try Android resolver version but its not fix it while if select force Android resolver version than i get gradle failed to fetch dependencies message.

 AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.ads.MobileAds
    java.lang.ClassNotFoundException: com.google.android.gms.ads.MobileAds
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:400)
        at java.lang.Class.forName(Class.java:326)
        at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
        at com.unity3d.player.UnityPlayer.c(Unknown Source)
        at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source)
        at android.os.MessageQueue.next(MessageQueue.java:392)
        at android.os.Looper.loop(Looper.java:136)
        at com.unity3d.player.UnityPlayer$e.run(Unknown Source)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAds" on path: DexPathList[[zip file "/data/app/com.HSquare.PaintIt-2/base.apk"],nativeLibraryDirectories=[/data/app/com.HSquare.PaintIt-2/lib/arm, /data/app/com.HSquare.PaintIt-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexC

3 Answers 3

3

In unity editor, Assets > Play Services Resolver > Android Resolver > Force Resolve

This will download the miss libraries.

1
  • Thanks, it works clearly now. But i didn't see any ads. I'm not sure about it. But game is work properly. Feb 24, 2021 at 3:52
2

If you're using ProGuard, make sure to set a custom proguard file. For me what worked was this:

-keep class com.google.unity.** {
   *;
}
-keep public class com.google.android.gms.ads.**{
   public *;
}
-keep public class com.google.ads.**{
   public *;
}
-keepattributes *Annotation*
-dontobfuscate

As shown here.

I'm not sure if "dontobfuscate" would be applied for the whole app though, seems like it might, and I haven't tested it without it.

0
1

Error seems your com.google.android.gms.ads.MobileAds Plugin not found in your apk.

Makesure your Unity project's Android plugin folder contains all necessary files imported for Admob plugin.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.