UNITY - AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener

7,048 views
Skip to first unread message

Jack

unread,
Aug 23, 2019, 5:33:08 AM8/23/19
to google-adm...@googlegroups.com
Hello, I'm using Google Mobile Ads Mediation on Unity. Version v3.18.2. Its include some network adapter: FAN, IronSource and UnityAds.
On GoogleMobileAdsDependencies have defaut androidPackage: com.google.android.gms:play-services-ads:18.1.1, when I use PlayServicesResolver to Resolve libraries depend on dependencies, it'll pull androidx but these libs is conflict with some other legacy libs when build, so I try to modify it to com.google.android.gms:play-services-ads:17.2.0 to avoid pull those androix and it built success. 
Inside project, I also have proguard-user file to keep important classes in final build. 

When I try to open game and see log on Android Studio, it logged like this:

2019-08-23 15:08:19.484 11659-11717/? E/Unity: AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener
    java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener
        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)

Game's not crashed, but Ads fail to initialize and no Ads at all. I look back to proguard-user file to check whether or not keep the class, but it fine. 
Here are some line in proguard-user file to keep the class.


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

And here is current plugin in Plugins/Android:

Libs.PNG


I dont know what i'm missing. Anyone have and idea for this problem.
P.s I searched lots of page on Google but there're no workaround to fix it.

Jack

unread,
Aug 23, 2019, 6:33:31 AM8/23/19
to Google Mobile Ads SDK Developers
I workaround and find out that, newest Google Mobile Ads Mediation have several code that call Java static com.google.android.gms.ads.initialization.OnInitializationCompleteListener. But if we down dependency to 17.2.0, it'll pull libs, that did not have class: OnInitializationCompleteListener. So I need to download old  Google Mobile Ads version, which do  not have OnInitializationCompleteListener.

Mobile Ads SDK Forum Advisor Prod

unread,
Aug 23, 2019, 6:50:31 AM8/23/19
to minnle...@gmail.com, google-adm...@googlegroups.com
Hi Jack,

Thank you for reaching out to us. Could you please provide the following details for us to investigate the issue further? Please use the "Reply Privately to Author" option to share the details privately.
  • Copy of sample project (with the issue reproduced)
  • FAN unitypackage version
  • UnityAds unitypackage version
  • Unity version
  • App ID and Ad Unit ID in question
Regards,
Teejay Pimentel
Mobile Ads SDK Team

ref:_00D1U1174p._5001UHETgG:ref

Jack

unread,
Aug 23, 2019, 7:19:08 AM8/23/19
to Google Mobile Ads SDK Developers

Hi Teejay, here is some details (I'm not gonna reply Privately, sorry about that)

- FAN 2.40
- IronSource: 1.2.0 (it's dependencies that I have to down to: androidPackage spec="com.google.ads.mediation:ironsource:6.8.4.1", that will not pull androidx libraries.
- UnityAds: 2.1.0
- AppID and Ad Unit ID, sorry, I can't share it.

In my game, admob is working fine now. All I have to do is download version GAM that did not have new Initialization API (see picture below). In this case, we can download v3.18

Notes.PNG

Computer Lunch

unread,
Sep 5, 2019, 9:08:36 PM9/5/19
to Google Mobile Ads SDK Developers
We are also struggling to get AdMob mediation from iron source. We get an error crash when the IronSrc AdMob module initiates in in the app. The app crashes immediately after this error.

We have the latest Google Play Game Services and
We have Google Mobile Ads v3.18.0


We seems to have AndroidX installed although it's unclear it that is the issue.


"com.google.android.gms.ads.initialization.OnInitializationCompleteListener"

Caused by: java.lang.ClassNotFoundException: Didn\'t find class \"com.google.android.gms.ads.initialization.OnInitializationCompleteListener\" on path: DexPathList[[zip file \"/data/app/com.computerlunch.evolution-2/base.apk\"],nativeLibraryDirectories=[/data/app/com.computerlunch.evolution-2/lib/arm64, /data/app/com.computerlunch.evolution-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

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.ironsource.mediationsdk.AbstractAdUnitManager.getLoadedAdapterOrFetchByReflection(AbstractAdUnitManager.java:182)
at com.ironsource.mediationsdk.RewardedVideoManager.startAdapter(RewardedVideoManager.java:500)
at com.ironsource.mediationsdk.RewardedVideoManager.loadNextAdapter(RewardedVideoManager.java:546)
at com.ironsource.mediationsdk.RewardedVideoManager.initRewardedVideo(RewardedVideoManager.java:107)
at com.ironsource.mediationsdk.IronSourceObject.startRewardedVideo(IronSourceObject.java:591)
at com.ironsource.mediationsdk.IronSourceObject.startAdUnit(IronSourceObject.java:456)
at com.ironsource.mediationsdk.IronSourceObject.onInitSuccess(IronSourceObject.java:441)
at com.ironsource.mediationsdk.MediationInitializer$1.run(MediationInitializer.java:184)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)

Mobile Ads SDK Forum Advisor Prod

unread,
Sep 6, 2019, 2:40:17 PM9/6/19
to and...@gutpela.com, google-adm...@googlegroups.com
Hello there,

It seems like the Google Mobile Ads Android dependencies were not properly imported into your Unity project. You are probably not getting the right version of the android SDK from jar resolver. That said, could you a follow this guide and import the 3.18.3 plugin and try executing dependency resolution by going to Assets > Play Services Resolver > Android Resolver > Resolve in your Unity IDE, then see if the error persists?

If you still see the error, please  provide us privately (using Reply privately to author option) a copy of your Unity project in question so we can also test it on our end.

Regards,
Deepika Uragayala

Computer Lunch

unread,
Sep 11, 2019, 1:12:27 PM9/11/19
to Google Mobile Ads SDK Developers
Hi Deepika,

Thanks for the direction i was able to get the error regarding "OnInitializationCompleteListener" working. Now we are stuck on a inventory issue but I've made another ticket for that. 

Thank you again for helping with our AdMob issues. :-D

Andrew
ComputerLunch.com

eanjo...@gmail.com

unread,
Mar 8, 2021, 10:38:24 PM3/8/21
to Google Mobile Ads SDK Developers
Hi.,

I have download the latest admob, In unity editor the test ads are showing and there is no bug.
But when I build the apk and install it, at the start of the app this error shows up.
Screen Shot 2021-03-09 at 11.34.16 AM.png

I follow everystep on the documentation many times trial and error using force resolve or resolve.

PLEASE HELP, its always like this when admob made a plugin its not reliable buggy at the start :(

Mobile Ads SDK Forum Advisor Prod

unread,
Mar 9, 2021, 4:19:30 AM3/9/21
to eanjo...@gmail.com, google-adm...@googlegroups.com
Hi there,

Thank you for bringing this to us.

Upon checking in our sample project and importing the plugin in the unity editor, I didn’t encounter any errors in building the project. I attached a screenshot of my console log for your reference. With this, could you please provide a project (or at least a test project) replicating the issue via Reply privately to author option or sending it directly to mobileadstesting99@gmail.com, so I could further investigate? 

Regards,
Google Logo
Teejay Wennie Pimentel
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2DMHvh:ref
Screen Shot 2021-03-09 at 4.37.48 PM.png

eanjo...@gmail.com

unread,
Mar 9, 2021, 5:33:52 AM3/9/21
to Google Mobile Ads SDK Developers
Hi thank you for your reply!!

IT WORKS! PLS UPDATE YOUR PLUGIN HERE: 


THAT ONE DOES NOT WORK AND ITS ON PUBLIC! 
when you search on Google for "unity admob plugun" that link will showup which has BUG!

THE LINK THAT YOU GAVE ME FOR THE PLUGIN:

 IS THE ONE WHICH IS WORKING!!!

PLS UPDATE IT GOOGLE THANK YOU!


On Tuesday, March 9, 2021 at 5:19:30 PM UTC+8 mobileadssdkforumadvisor wrote:
Hi there,

Thank you for bringing this to us.

Upon checking in our sample project and importing the plugin in the unity editor, I didn’t encounter any errors in building the project. I attached a screenshot of my console log for your reference. With this, could you please provide a project (or at least a test project) replicating the issue via Reply privately to author option or sending it directly to mobileads...@gmail.com, so I could further investigate? 
Reply all
Reply to author
Forward
0 new messages