Unity application crashes on my device

I created a Unity game that includes AdMob services (plugin) when a player dies. When testing the application in the editor, everything works fine. But when I copy apk to an Android phone and get to the point in the game where the player dies, it crashes.

With Logcat, I found the exception that was thrown:

10-29 11:46:36.806 29956 29956 E AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/MobileAds; 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at com.google.unity.ads.RewardBasedVideo$1.run(RewardBasedVideo.java:65) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:746) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5443) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAds" on path: DexPathList[[zip file "/data/app/com.comp.game-1/base.apk"],nativeLibraryDirectories=[/data/app/com.comp.game-1/lib/arm, /data/app/com.comp.game-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:469) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: ... 8 more 10-29 11:46:36.806 29956 29956 E AndroidRuntime: Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.ads.MobileAds 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at java.lang.Class.classForName(Native Method) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at java.lang.BootClassLoader.findClass(ClassLoader.java:781) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) 10-29 11:46:36.806 29956 29956 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:504)10-29 11:46:36.806 29956 29956 E AndroidRuntime: ... 9 more 

I tried using Assets> Resolver Services Services> Android Solver> Allow Client Banks.

But the option "Allow client banners" is not executed. So I tried installing the plugin from here , but that didn't seem to be either.

I suppose this has something to do with the missing banks, but I don't know which ones and how to add them if you don't use the Jar resolver.

Oh, maybe it's worth mentioning the detail: I had to install an older version of the tools (tools_r25.2.5) so that it would not compile at all.

Thanks in advance.

+5
source share
2 answers

It is very possible that you are using some other dependencies that have a conflicting version of the Google Play services.

Make sure all your dependencies depend on the same version,

And make sure that the other plugins you have implemented do not use new or older versions of google play, firebase, or any other type of dependency that occurs more than once in two different versions.

Good luck.

+2
source

The resolver doest utility command works if the project has space with spaces. Remove the spaces from the project workspace, and then force the banks. Another problem might be the dependencies.xml file in your project.

+2
source

Source: https://habr.com/ru/post/1272973/


All Articles