In my Unity project, I used some assets like FacebookSDK, OneSignal etc. Whenever I import OneSignal, this error will be shown.
Google.JarResolver.ResolutionException: Cannot resolve com.google.firebase:firebase-analytics-unity:1.0.0()
I had tried many things, these are what I remember:
- Using 'Play Service Resolver' does not solve the problem.
- Importing Unity Firebase.
When I import Firebase, the error turn into another error, which is building error called CommandInvokationFailure
, related to Firebase.
I spent several days to fix it, but still I couldn't. If you need further information, tell me please.
EDIT: @nika Thanks for reply. I tried every combination of API 23-24-25 and build tools from 23 to 25. But, I can't fix 'CommandInvokationFailure' yet. I think sharing the full log of the error will be better:
CommandInvokationFailure: Unable to convert classes into dex format.
/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/emre/Desktop/AndroidSDK/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar" -
stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzah;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzcn;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/BuildConfig;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoJellyBeanMr2;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/animation/AnimatorCompatHelper;
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:608)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at SDKMain.main(SDKMain.java:129)
Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:600)
... 9 more
]
EDIT 2: @jkasten Thanks for reply. I can fix Android Support Library v4 Errors, however, for the second one is not easy because of resolvers.
There is no duplicated play-services files. This time, I improvised to solve it: removing play-services-ads-9.0.1 from android build by changing import settings(if other ads file is removed, the CommandInvokationFailure
error continues.). I don't really know it is the right way to solve the problem, but it worked somehow. But it leads me another error when I tried to run game on my phone:
FATAL EXCEPTION: main
E/AndroidRuntime(18680): java.lang.NoSuchMethodError: No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzaa; or its super classes (declaration of 'com.google.android.gms.common.internal.zzaa' appears in /data/app/***/base.apk)
E/AndroidRuntime(18680): at com.google.firebase.provider.FirebaseInitProvider.zza(Unknown Source)
E/AndroidRuntime(18680): at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
E/AndroidRuntime(18680): at android.app.ActivityThread.installProvider(ActivityThread.java:5159)
E/AndroidRuntime(18680): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4754)
E/AndroidRuntime(18680): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4694)
E/AndroidRuntime(18680): at android.app.ActivityThread.access$1600(ActivityThread.java:150)
E/AndroidRuntime(18680): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
E/AndroidRuntime(18680): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(18680): at android.os.Looper.loop(Looper.java:148)
E/AndroidRuntime(18680): at android.app.ActivityThread.main(ActivityThread.java:5423)
E/AndroidRuntime(18680): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18680): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
E/AndroidRuntime(18680): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
This question mentions a few different errors. All are eventually related to issues with native Android libraries (.jar or .aar) within the Unity project.
I'll try to address all of the issues you mentioned:
Cannot resolve (library name)
A lot of Android plugins use the Play Services Resolver - this is helper code that attempts to simplify things by automatically resolving the needed Google play services libraries (located under the Android SDK folder).
It works by setting the needed dependencies to a static instance of a class, which then attempts to resolve the needed libraries. Sometimes, the operation of the resolver can fail, since it may become "out of sync" with its persisted data.
In this case, what probably happened is that the static object was still attempting to resolve the "firebase-analytics-unity" library, but this folder was removed from the project, so it failed to look it up.
Already Added Lxxx/xxx/xxx
As was already answered by @jkasten, your project contains multiple plugins that contain the same compiled Java classes. The hint as to which library is duplicated can be found by the class names (not always helpful though). In this case, you can see that it's related to com.google.android.gms (google play services) and Android support library (android.support.v4.xxx).
No static method zzb
This is a more subtle and tricky one. The game was built into an .apk, but crashes at runtime due to a class that is not found. Judging by the method name (zzb) - this is an internal "obfuscated" method inside Google play services. This can happen if you mix multiple versions of google play services together (for example - Firebase at version 9.8.0 with Google play services at a different version).
It's vital to keep all these versions consistent with one another, a task that could sometimes get a bit tricky with the Resolver that does this automatically.
Final Note:
I offer a professional service to assist fixing such issues. Please feel free to contact me in case you run into a similar issue in the future.
From the following two unique lines in your log:
This means there are 2 or more copies of the
Google Play services library
and theAndroid Support Library v4
in your project.Fixing the Android Support Library v4 Errors (support/v4)
In order to use the OneSignal and Facebook SDKs together in the same Unity project you will need to delete the following duplicated libraries noted in the OneSignal troubleshooting guide.
This will fix the
already added: Landroid/support/v4
errors unless their is a 3rd plugin with this library as well in your project.Fixing the Google Play services library Errors (gms)
I recommend deleting duplicate
play-services-[library]-[version].aar
files in your Unity project. There will be different[libraries]
however there should only be a single version for allplay-services-*.aar
files. This should fix thealready added: Lcom/google/android/gms
errors.If you get stuck update your question with a full list of plugins with version numbers. Also list all
.aar
and.jar
files in your project. Additional you can create a new project and add one plugin at a time until you get the error to pin point the plugin combination creating the issue.