Reputation: 367
I have created a Unity game, which includes AdMob services (plugin), when the player dies. When testing the app in editor everything works just fine. But when I copy the apk to an android phone, and get to the point in the game, where the player dies, it crashes.
Using 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 have tried using Assets > Play Services Resolver > Android Resolver > Resolve Client Jars.
But the option "Resolve Client Jars" doesn't exsit. So I tried installing the plugin from here, but that didn't make it appear either.
I'm guessing it has something to do with missing jars, but I don't know which ones and how to add them, if not using the Jar resolver.
Oh, a detail maybe worth mentioning: I had to install an older version of the tools (tools_r25.2.5), for it to compile at all.
Thanks in advance.
Upvotes: 4
Views: 1077
Reputation: 289
Play services resolver doest work if you project workspace has spaces. Remove spaces from your project workspace then force resolve jars. Other issue can be missing dependencies.xml file in your project.
Upvotes: 2
Reputation: 2654
It is very possible that you are using some other dependencies that have a conflicting version of google play services.
Make sure all your dependencies are relying on the same version,
And verify that other plugins you have implemented dont use newer or older versions of google play services ,or firebase , or any other type of dependency, that is there more than once in two different versions.
Good luck
Upvotes: 3