googleads-mobile-unity
googleads-mobile-unity copied to clipboard
Error intialising 7.2.0 on android
[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)
Same
@segant08
This looks like the External Dependency Manager failed to resolve dependencies. Try doing a Force Resolve first, and make sure all dependency are being pulled down correctly.
Assets > External Dependency Manager > Android Settings > Force Resolve
Hi @NVentimiglia thanks for your recommendation, I've tried doing a force resolve and also tried re-importing the plugin then force resolving again and get the same error when building to the apk.
When removing the plugin is there any other steps then deleting the folders i listed in the original post?
- quote from original post "I've tried deleting the relevant folders (ExternalDependencies and GoogleMobileAds), as well as all the relevant files in the Plugins folder"
@segant08
This looks like the External Dependency Manager failed to resolve dependencies. Try doing a Force Resolve first, and make sure all dependency are being pulled down correctly.
Assets > External Dependency Manager > Android Settings > Force Resolve
@NVentimiglia how can I make sure all dependency are being pulled down correctly, where should I check? Please let me know.
If I do force resolve, it shows resolution succeeded.
I am also facing the same issue with plugin version 7.2.0 after building to android device, and as the initialization is not happening ads are also not loading.
java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener
from logcat.
@LMBooth did you manage to fix the issue? Please let me know.
Nope, still having the same issue. I've been preoccupied with some other projects recently but i'm going to try a fresh project and try to reimport my assets from scratch to see if that has any luck, but probably won't get round to it until mid October with my current schedule.
@LMBooth thanks for replying, I was also not able to do a successful build with 7.2.0, so switched back to 7.1.0 and it is working fine. Please let me know if you have success with 7.2.0 in future, all the best to you.
No problem @ChaserKnight , since you've had luck with 7.1.0 i may switch to that version too, thanks for the recommendation!
Switched to 7.1.0, adds are loading now.
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.
Thanks @ikoukas that fix works too!