question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error intialising 7.2.0 on android

See original GitHub issue

[REQUIRED] Step 1: Describe your environment

  • Unity version: 2021.3.8f1
  • Google Mobile Ads Unity plugin version: 7.2.0
  • Platform: Android
  • Platform OS version: Android 10

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

Imported admob 7.2.0, initialised MobileAds with:

MobileAds.Initialize(initStatus => {});

I get the following errors whilst initialising via the android logcat:

2022/09/02 18:10:49.808 29845 29845 Debug Surface lockCanvas
2022/09/02 18:10:49.899 29845 29938 Info IL2CPP Locale en-GB
2022/09/02 18:10:52.681 29845 29873 Info Unity Beginning Initialization...
2022/09/02 18:10:52.681 29845 29873 Info Unity  #0 0x7e692d49 (libunity.so) ? 0x0
2022/09/02 18:10:52.681 29845 29873 Info Unity  #1 0x7e9f0cdf (libunity.so) ? 0x0
2022/09/02 18:10:52.681 29845 29873 Info Unity  #2 0x7e4bd229 (libunity.so) ? 0x0
2022/09/02 18:10:52.681 29845 29873 Info Unity  #3 0x7e4bd175 (libunity.so) ? 0x0
2022/09/02 18:10:52.681 29845 29873 Info Unity  #4 0x7d665090 (libil2cpp.so) DebugLogHandler_Internal_Log_m20852F18A88BB18425BA07260545E3968F7EA76C 0x84
2022/09/02 18:10:52.681 29845 29873 Info Unity  #5 0x7d6651b0 (libil2cpp.so) DebugLogHandler_LogFormat_m216B169EF9B669F2ED4C59F6B9F326D4EBBDF821 0x7c
2022/09/02 18:10:52.681 29845 29873 Info Unity  #6 0x7bde24d4 (libil2cpp.so) InterfaceActionInvoker4<int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Object_tC12DECB6760A7F2CBF65D9DCF18D044C2D97152C*, String_t*, ObjectU5BU5D_t8061030B0A12A55D5AD8652A20C922FE99450918*) 0x270
2022/09/02 18:10:52.681 29845 29873 Info Unity  #7 0x7d68816c (libil2cpp.so) Logger_Log_mEA3D39763D610E92491AA479BA653ECFEE3E9E5C 0x198
2022/09/02 18:10:52.681 29845 29873 Info Unity  #8 0x7bbb7d98 (libil2cpp.so) InterfaceActionInvoker2<int, Il2CppObject*>::Invoke(unsigned short, Il2CppClass*, Il2CppObject*, int, Il2CppObject*) 0x258
2022/09/02 18:10:52.681 29845 29873 Info Unity  #9 0x7d665534 (libil2cpp.so) Debug_Log_m87A
2022/09/02 18:10:52.783 29845 29873 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener
2022/09/02 18:10:52.783 29845 29873 Error Unity java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener
2022/09/02 18:10:52.783 29845 29873 Error Unity 	at java.lang.Class.classForName(Native Method)
2022/09/02 18:10:52.783 29845 29873 Error Unity 	at java.lang.Class.forName(Class.java:454)
2022/09/02 18:10:52.783 29845 29873 Error Unity 	at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
2022/09/02 18:10:52.783 29845 29873 Error Unity 	at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
2022/09/02 18:10:52.783 29845 29873 Error Unity 	at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:83)
2022/09/02 18:10:52.783 29845 29873 Error Unity 	at android.os.Handler.dispatchMessage(Handler.java:103)
2022/09/02 18:10:52.783 29845 29873 Error Unity 	at android.os.Looper.loop(Looper.java:214)
2022/09/02 18:10:52.783 29845 29873 Error Unity 	at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
2022/09/02 18:10:52.783 29845 29873 Error Unity Caused by: java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener
2022/09/02 18:10:52.783 29845 29873 Error Unity 	... 8 more
2022/09/02 18:10:52.783 29845 29873 Error Unity   at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 
2022/09/02 18:10:52.783 29845 29873 Error Unity   at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <000000000000000000000

I’ve tried deleting the relevant folders (ExternalDependencies and GoogleMobileAds), as well as all the relevant files in the Plugins folder, then i’ve reimported the package and re-resolved the android dependencies to see if that would fix the issue but have no luck.

In the editor everything initialises and the test ads load, but no luck when i build and install my apk. If anyone has any ideas or gone through anything similar and could share their experiences, that’d be great!

For some more info: I’ve got my current app store id set on the Google Mobile Ads Settings too, which i can validate that it updates the android manifest with the same id. (in addition, my app is already published on the play store and i have my account validated on AdMob with the status of my app saying it’s ready if any of those make a difference. Only just switched to Admob from Unity)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ikoukascommented, Oct 16, 2022

You need to add a proguard-user.txt file to your project from the build settings, and add this line to it -keep,includedescriptorclasses public class com.google.** { *; } I had the same issue after 7.2.0 and it fixed it. The answer above about the class not found error gave me the clue.

1reaction
LMBoothcommented, Oct 16, 2022

Thanks @ikoukas that fix works too!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Known issues with Android Studio and Android Gradle Plugin
Known Issues with Android Studio · Firebase assistant window displays an error message · Compose nodes are not all inspectable using Layout Inspector...
Read more >
Error running android: Gradle project sync failed. Please fix ...
Go to File -> Invalidate Caches/Restart · Shutdown Android Studio · Rename/remove your .gradle folder in the user home directory · Restart Android ......
Read more >
Can't build after updating to AGP 7.2.0-alpha04 [205856789]
AgpVersionAttr' with value '7.2.0-alpha04' but the consumer didn't ask for it - Provides attribute 'com.android.build.api.attributes.
Read more >
SFMCSdk Android : Home
JSONObject Verifier Error Resolved – A fix for the on-init crash has been implemented ... Version 7.2.0 of the Android SDK has been...
Read more >
Unable to compile for Android after using Google's AdMob ...
but this message shows up and this error comes up when I play the game in Editor: Code (CSharp):. NullReferenceException: Object reference not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found