firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
819 stars 424 forks source link

[Bug] Error when running after building with Firebase 8.10.1 #1268

Closed henry-dreamo closed 2 years ago

henry-dreamo commented 2 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

I was using Firebase 8.9.0 well before. I updated it after 8.10.0 came out and it went without any problems, but some developers had problems with python in the editor, so I updated it to 8.10.1. The python-related problem disappeared in the editor, but the following error occurred when running after build.

field_ids[i] || (field.optional == kMethodOptional)

Firebase.Crashlytics.CrashlyticsInternalPINVOKE:FirebaseCrashlyticsInternal_GetInstance__SWIG_0(HandleRef, Int32&)
Firebase.Crashlytics.FirebaseCrashlyticsInternal:GetInstance(FirebaseApp, InitResult&)
Firebase.Crashlytics.AndroidImpl:.ctor()
Firebase.Crashlytics.Impl:Make()
Firebase.Crashlytics.PlatformAccessor:.cctor()
Firebase.Crashlytics.Crashlytics:Initialize()
System.Reflection.RuntimeMethodInfo:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
Firebase.FirebaseApp:InitializeCrashlyticsIfPresent()
Firebase.FirebaseApp:CreateAndTrack(CreateDelegate, FirebaseApp)
JH.<>c:<PreLoadFirebase>b__208_1(Boolean, DependencyStatus)
Firebase.Extensions.<>c__DisplayClass4_1`1:<ContinueWithOnMainThread>b__1()
Firebase.<>c__DisplayClass5_0`1:<RunAsync>b__0()
Firebase.ExceptionAggregator:Wrap(Action)
Firebase.Dispatcher:PollJobs()
Firebase.Platform.FirebaseHandler:Update()
ApplicationException: Unable to find Field com/google/firebase/crashlytics/FirebaseCrashlytics.core (signature 'Lcom/google/firebase/crashlytics/internal/common/CrashlyticsCore;', instance).  Please verify the AAR which contains the com/google/firebase/crashlytics/FirebaseCrashlytics class is included in your app.

Firebase.Crashlytics.FirebaseCrashlyticsInternal.GetInstance (Firebase.FirebaseApp app, Firebase.InitResult& init_result_out) (at <00000000000000000000000000000000>:0)
Firebase.Crashlytics.AndroidImpl..ctor () (at <00000000000000000000000000000000>:0)
Firebase.Crashlytics.Impl.Make () (at <00000000000000000000000000000000>:0)
Firebase.Crashlytics.Crashlytics+PlatformAccessor..cctor () (at <00000000000000000000000000000000>:0)
Firebase.Crashlytics.Crashlytics.Initialize () (at <00000000000000000000000000000000>:0)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <00000000000000000000000000000000>:0)
Firebase.FirebaseApp.InitializeCrashlyticsIfPresent () (at <00000000000000000000000000000000>:0)
Firebase.FirebaseApp.CreateAndTrack (Firebase.FirebaseApp+CreateDelegate createDelegate, Firebase.FirebaseApp existingProxy) (at <00000000000000000000000000000000>:0)
JH.FirebaseManager+<>c.<PreLoadFirebase>b__208_1 (System.Boolean success, Firebase.DependencyStatus depStatus) (at <00000000000000000000000000000000>:0)
Firebase.Extensions.TaskExtension+<>c__DisplayClass4_1`1[T].<ContinueWithOnMainThread>b__1 () (at <00000000000000000000000000000000>:0)
Firebase.Dispatcher+<>c__DisplayClass5_0`1[TResult].<RunAsync>b__0 () (at <00000000000000000000000000000000>:0)
Firebase.ExceptionAggregator.Wrap (System.Action action) (at <00000000000000000000000000000000>:0)
Firebase.Dispatcher.PollJobs () (at <00000000000000000000000000000000>:0)
Firebase.Platform.FirebaseHandler.Update () (at <00000000000000000000000000000000>:0)
Rethrow as TypeInitializationException: The type initializer for 'Firebase.Crashlytics.Crashlytics.PlatformAccessor' threw an exception.
Firebase.Crashlytics.Crashlytics.Initialize () (at <00000000000000000000000000000000>:0)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <00000000000000000000000000000000>:0)
Firebase.FirebaseApp.InitializeCrashlyticsIfPresent () (at <00000000000000000000000000000000>:0)
Firebase.FirebaseApp.CreateAndTrack (Firebase.FirebaseApp+CreateDelegate createDelegate, Firebase.FirebaseApp existingProxy) (at <00000000000000000000000000000000>:0)
JH.FirebaseManager+<>c.<PreLoadFirebase>b__208_1 (System.Boolean success, Firebase.DependencyStatus depStatus) (at <00000000000000000000000000000000>:0)
Firebase.Extensions.TaskExtension+<>c__DisplayClass4_1`1[T].<ContinueWithOnMainThread>b__1 () (at <00000000000000000000000000000000>:0)
Firebase.Dispatcher+<>c__DisplayClass5_0`1[TResult].<RunAsync>b__0 () (at <00000000000000000000000000000000>:0)
Firebase.ExceptionAggregator.Wrap (System.Action action) (at <00000000000000000000000000000000>:0)
Firebase.Dispatcher.PollJobs () (at <00000000000000000000000000000000>:0)
Firebase.Platform.FirebaseHandler.Update () (at <00000000000000000000000000000000>:0)
Scene.<Start>d__11:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Link that came up with a similar issue when I searched it, but it is different from the current version. I was wondering if there is a way to temporarily solve this issue in the current state.

Steps to reproduce:

Import and install Firebase Unity 8.10.1 and build for Android. An error log occurs with a 100% probability when running after build.

I didn't have time to go ahead with the QuickStart project.

a-maurice commented 2 years ago

Hi @henry-dreamo

In your Unity project, under Assets/Plugins/Android, it should have all the Android dependencies it is including. What versions of com.google.firebase.firebase-crashlytics and com.google.firebase.firebase-crashlytics-ndk do you have?

henry-dreamo commented 2 years ago

Hi @a-maurice

mainTemplate.gradle

image

Assets/Firebase/Editor/CrashlyticsDependencies.xml com.google.firebase:firebase-crashlytics-ndk:18.2.9 com.google.firebase:firebase-analytics:20.1.2 com.google.firebase:firebase-crashlytics-unity:8.10.1

After build, FirebaseApp.androidlib and FirebaseCrashlytics.androidlib folders are created.

image

nfcodes commented 2 years ago

@a-maurice

Having the same issue after update from 8.9.0 to 8.10.1

a-maurice commented 2 years ago

Ah, so the problem seems to be when enabling minification, it is not preserving the Android library symbols correctly. We will see if we can get this fixed, and find a workaround in the meantime.

a-maurice commented 2 years ago

Alright, for a workaround you can add the following to your custom proguard-user.txt file:

-keep,includedescriptorclasses public class com.google.firebase.crashlytics.FirebaseCrashlytics { *; }
-keep,includedescriptorclasses public class com.google.firebase.crashlytics.internal.common.CrashlyticsCore { *; }
-keep,includedescriptorclasses public class com.google.firebase.crashlytics.internal.common.DataCollectionArbiter { *; }
-keep,includedescriptorclasses public class com.google.firebase.crashlytics.ndk.FirebaseCrashlyticsNdk { *; }
-keep class com.google.firebase.crashlytics.ndk.** { *; }
AlmostMatt commented 2 years ago

A fix for this issue was merged in https://github.com/firebase/firebase-unity-sdk/pull/289, and this fix will be part of the upcoming 9.0 release of the Unity SDK.

In the meantime, you can use the workaround that Anthony provided just above and manually edit the custom proguard-user.txt file