Google.JarResolver.ResolutionException: Cannot resolve com.google.firebase:firebase-analytics-unity:1.0.0()

后端 未结 2 1179
攒了一身酷
攒了一身酷 2020-12-19 21:07

In my Unity project, I used some assets like FacebookSDK, OneSignal etc. Whenever I import OneSignal, this error will be shown.

Google.JarResolver.Re

2条回答
  •  轮回少年
    2020-12-19 21:22

    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)

    Google.JarResolver.ResolutionException: Cannot resolve com.google.firebase:firebase-analytics-unity:1.0.0()

    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

    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;

    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

    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)

    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.

提交回复
热议问题