AndroidJavaException: java.lang.ClassNotFoundException: com.google.unity.ads.UnityInterstitialAdCallback
Hi, I added Admob into my game and my test ads works on unity editor perfectly and ı don't get any error. However when ı get build for my android device, Ads doesn't show and I get error for this line :
this.interstitial = new InterstitialAd(adUnitId);
And Error :
AndroidJavaException: java.lang.ClassNotFoundException: com.google.unity.ads.UnityInterstitialAdCallback java.lang.ClassNotFoundException: com.google.unity.ads.UnityInterstitialAdCallback java.lang.Class.classForName(Native Method) java.lang.Class.forName(Class.java:453) com.unity3d.player.UnityPlayer.nativeRender(Native Method) com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) android.os.Handler.dispatchMessage(Handler.java:102) android.os.Looper.loop(Looper.java:207) com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.unity.ads.UnityInterstitialAdCallback" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.YDMGames.SpeedJump-ynPejBOzfqyFoPjZJbTLfw==/base.apk"],nativeLibraryDirectories=[/data/app/com.YDMGames.SpeedJump-ynPejBOzfqyFoPjZJbTLfw==/lib/arm64, /data/app/com.YDMGames.SpeedJump-ynPejBOzfqyFoPjZJbTLfw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]] dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171) java.lang.ClassLoader.loadClass(ClassLoader.java:379) java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 8 more UnityEngine.AndroidJNISafe.CheckException () (at :0) UnityEngine.AndroidJNISafe.FindClass (System.String name) (at :0) UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) (at :0) UnityEngine.AndroidJavaProxy..ctor (System.String javaInterface) (at :0) GoogleMobileAds.Android.InterstitialClient..ctor () (at :0) GoogleMobileAds.GoogleMobileAdsClientFactory.BuildInterstitialClient () (at :0) GoogleMobileAds.Api.InterstitialAd..ctor (System.String adUnitId) (at :0) AdmobScriptt.RequestInterstitial () (at :0) AdmobScriptt.Start () (at :0)
Answer by ImPHL1 · Mar 30 at 02:25 PM
Hi, I had a similar error and i fixed it tnx to this blog post: link text
resolve Android dependencies (Assets > External Dependency Manager > Android Resolver > Resolve) then enable Proguard File (Project Setting > Player > Publishing Settings) and then change it to 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
you can find proguard file under the : Assets\Plugins\Android\proguard-user.txt
Your answer
![](https://koobas.hobune.stream/wayback/20220613042149im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Hi Everyone Please help me with Unity And Admob integration 0 Answers
admob banner ad not showing 0 Answers
How to Show Admob interstitial ads more one time after Gameover? 0 Answers
Unity Google AdMob Banner 2 Answers
adMob ads are black 2 Answers