Estoy usando Unity y Firebase. No se puede configurar. He leído detenidamente toda la documentación varias veces. He revisado todos sus proyectos de muestra. ¡He probado todo lo que puedo pensar! Tengo el siguiente código:

private void Start()
{
    FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>  //Also tried ContinueWithMainThread
    {
        var dependencyStatus = task.Result;
        if (dependencyStatus == DependencyStatus.Available)
        {
            //I tried waiting 5 seconds here
            Debug.Log("Initializing Firebase");
            //Get error when I call the following line (and no error if I don't)
            var firebaseApp = FirebaseApp.DefaultInstance;
            Debug.Log("Firebase Initialized");
        }
        else
        {
            Debug.LogError($"Could not resolve all Firebase dependencies: {dependencyStatus}");
        }
    });
}

Tengo entendido que Firebase no es seguro de usar hasta que reciba el DependencyStatus de Available. Entonces eso es lo que estoy haciendo. Registré todo a fondo y Firebase no está configurado, aunque obtengo un estado de dependencia Available. Recibo el siguiente error cuando intento inicializar mi FirebaseApp (o llamar a cualquier otra función de Firebase):

[Firebase / Core] [I-COR000003] La aplicación Firebase predeterminada aún no se ha configurado. Agrega [FIRApp configure]; (FirebaseApp.configure() en Swift) a la inicialización de tu aplicación.

Estoy usando la versión 6.15.2 de Firebase. Estoy en iOS. No tengo problemas para ejecutar en Android. Intenté eliminar todos los paquetes excepto Firebase App (Core), pero sigo recibiendo el mismo error. (Los registros tienen los paquetes incluidos).

A continuación, se muestran algunos registros detallados:

Initializing Firebase
Carbon.Firebase.FirebaseManager:<Start>b__27_0(Task`1)
System.Threading.ContextCallback:Invoke(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Runtime.CompilerServices.MoveNextRunner:Run()
System.Action:Invoke()
System.Threading.Tasks.AwaitTaskContinuation:RunOrScheduleAction(Action, Boolean, Task&)
System.Threading.Tasks.Task:FinishContinuations()
System.Threading.Tasks.Task`1:TrySetResult(TResult)
System.Threading.Tasks.DelayPromise:Complete()
System.Threading.TimerCallback:Invoke(Object)
System.Threading.WaitCallback:Invoke(Object)
System.Threading.ThreadPoolWorkQueue:Dispatch()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2020-08-23 20:59:12.807516-0400 v1[1160:269382] 6.24.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization.
2020-08-23 20:59:12.876636-0400 v1[1160:269421] 6.24.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2020-08-23 20:59:12.887162-0400 v1[1160:269243] [Firebase/Crashlytics] Version 4.1.0
2020-08-23 20:59:12.911808-0400 v1[1160:269417] 6.24.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60500000 started
2020-08-23 20:59:12.912317-0400 v1[1160:269417] 6.24.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2020-08-23 20:59:13.045633-0400 v1[1160:269489] Remote Config API Initializing
2020-08-23 20:59:13.055122-0400 v1[1160:269243] FCM: registration token received, but no listener set yet - cached the token.
Remote Config API Initializing
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

FCM: registration token received, but no listener set yet - cached the token.
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2020-08-23 20:59:13.127161-0400 v1[1160:269489] Remote Config API Initialized
Remote Config API Initialized
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Firebase initialized
Carbon.Firebase.FirebaseManager:<Start>b__27_0(Task`1)
System.Threading.ContextCallback:Invoke(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Runtime.CompilerServices.MoveNextRunner:Run()
System.Action:Invoke()
System.Threading.Tasks.AwaitTaskContinuation:RunOrScheduleAction(Action, Boolean, Task&)
System.Threading.Tasks.Task:FinishContinuations()
System.Threading.Tasks.Task`1:TrySetResult(TResult)
System.Threading.Tasks.DelayPromise:Complete()
System.Threading.TimerCallback:Invoke(Object)
System.Threading.WaitCallback:Invoke(Object)
System.Threading.ThreadPoolWorkQueue:Dispatch()

Y para ser excesivo, aquí están los mismos registros, pero con la información de depuración activada:

2020-08-23 21:28:52.021254-0400 v1[1175:273744] UnityIAP: Requesting 2 products
2020-08-23 21:28:52.055821-0400 v1[1175:273744] DEBUG: Disabling all app initializers
2020-08-23 21:28:52.056433-0400 v1[1175:273744] DEBUG: Disable analytics
2020-08-23 21:28:52.056556-0400 v1[1175:273744] DEBUG: Disable functions
2020-08-23 21:28:52.056639-0400 v1[1175:273744] DEBUG: Disable messaging
2020-08-23 21:28:52.056728-0400 v1[1175:273744] DEBUG: Disable remote_config
Enable module 'analytics' for 'Firebase.Analytics.FirebaseAnalytics, Firebase.Analytics'
Firebase.FirebaseApp:InitializeAppUtilCallbacks()
Firebase.FirebaseApp:CheckDependenciesAsync()
Firebase.FirebaseApp:CheckAndFixDependenciesAsync()
Carbon.Firebase.FirebaseManager:Start()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2020-08-23 21:28:52.057256-0400 v1[1175:273744] DEBUG: analytics app initializer Enabling
2020-08-23 21:28:52.057441-0400 v1[1175:273744] DEBUG: App initializer auth not found, failed to enable.
2020-08-23 21:28:52.057647-0400 v1[1175:273744] DEBUG: App initializer crashlytics not found, failed to enable.
2020-08-23 21:28:52.060160-0400 v1[1175:273744] DEBUG: App initializer database not found, failed to enable.
2020-08-23 21:28:52.060332-0400 v1[1175:273744] DEBUG: App initializer dynamic_links not found, failed to enable.
Enable module 'functions' for 'Firebase.Functions.FirebaseFunctions, Firebase.Functions'
Firebase.FirebaseApp:InitializeAppUtilCallbacks()
Firebase.FirebaseApp:CheckDependenciesAsync()
Firebase.FirebaseApp:CheckAndFixDependenciesAsync()
Carbon.Firebase.FirebaseManager:Start()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2020-08-23 21:28:52.060646-0400 v1[1175:273744] DEBUG: functions app initializer Enabling
2020-08-23 21:28:52.060833-0400 v1[1175:273744] DEBUG: App initializer instance_id not found, failed to enable.
2020-08-23 21:28:52.060994-0400 v1[1175:273744] DEBUG: App initializer invites not found, failed to enable.
Enable module 'messaging' for 'Firebase.Messaging.FirebaseMessaging, Firebase.Messaging'
Firebase.FirebaseApp:InitializeAppUtilCallbacks()
Firebase.FirebaseApp:CheckDependenciesAsync()
Firebase.FirebaseApp:CheckAndFixDependenciesAsync()
Carbon.Firebase.FirebaseManager:Start()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2020-08-23 21:28:52.061372-0400 v1[1175:273744] DEBUG: messaging app initializer Enabling
2020-08-23 21:28:52.061569-0400 v1[1175:273744] DEBUG: App initializer performance not found, failed to enable.
Enable module 'remote_config' for 'Firebase.RemoteConfig.FirebaseRemoteConfig, Firebase.RemoteConfig'
Firebase.FirebaseApp:InitializeAppUtilCallbacks()
Firebase.FirebaseApp:CheckDependenciesAsync()
Firebase.FirebaseApp:CheckAndFixDependenciesAsync()
Carbon.Firebase.FirebaseManager:Start()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2020-08-23 21:28:52.061829-0400 v1[1175:273744] DEBUG: remote_config app initializer Enabling
2020-08-23 21:28:52.062019-0400 v1[1175:273744] DEBUG: App initializer storage not found, failed to enable.
2020-08-23 21:28:52.062175-0400 v1[1175:273744] DEBUG: App initializer test_lab not found, failed to enable.
Initializing Firebase
Carbon.Firebase.FirebaseManager:InitializeFirebase(DependencyStatus)
System.Action`1:Invoke(T)
System.Threading.Tasks.Task:Execute()
System.Threading.ContextCallback:Invoke(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&)
System.Threading.Tasks.Task:ExecuteEntry(Boolean)
System.Threading.ThreadPoolWorkQueue:Dispatch()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Disabling all app initializers
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Disable analytics
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Disable functions
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Disable messaging
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Disable remote_config
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

analytics app initializer Enabling
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

App initializer auth not found, failed to enable.
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

App initializer crashlytics not found, failed to enable.
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

App initializer database not found, failed to enable.
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

App initializer dynamic_links not found, failed to enable.
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

functions app initializer Enabling
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

App initializer instance_id not found, failed to enable.
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

App initializer invites not found, failed to enable.
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

messaging app initializer Enabling
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

App initializer performance not found, failed to enable.
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

remote_config app initializer Enabling
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

App initializer storage not found, failed to enable.
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

App initializer test_lab not found, failed to enable.
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2020-08-23 21:28:52.135579-0400 v1[1175:273986] DEBUG: Creating Firebase App __FIRAPP_DEFAULT for Firebase C++ 6.15.1
2020-08-23 21:28:52.153491-0400 v1[1175:273919] 6.24.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization.
Creating Firebase App __FIRAPP_DEFAULT for Firebase C++ 6.15.1
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2020-08-23 21:28:52.584552-0400 v1[1175:273744] UnityIAP: Requesting product data...
2020-08-23 21:28:52.627075-0400 v1[1175:273744] [Firebase/Crashlytics] Version 4.1.0
2020-08-23 21:28:52.677262-0400 v1[1175:273986] DEBUG: Added app name=__FIRAPP_DEFAULT: options, api_key=AIzaSyDfYwUh8pet1DBg-h_Z3aBisGM7-O0pa00, app_id=1:357282509732:ios:0a7799bd3c86c224558731, database_url=https://carbon-weight-loss-v1.firebaseio.com, messaging_sender_id=357282509732, storage_bucket=carbon-weight-loss-v1.appspot.com, project_id=carbon-weight-loss-v1 (0x11a2ca90)
2020-08-23 21:28:52.710093-0400 v1[1175:273986] Remote Config API Initializing
2020-08-23 21:28:52.745216-0400 v1[1175:273986] Remote Config API Initialized
Added app name=__FIRAPP_DEFAULT: options, api_key=AIzaSyDfYwUh8pet1DBg-h_Z3aBisGM7-O0pa00, app_id=1:357282509732:ios:0a7799bd3c86c224558731, database_url=https://carbon-weight-loss-v1.firebaseio.com, messaging_sender_id=357282509732, storage_bucket=carbon-weight-loss-v1.appspot.com, project_id=carbon-weight-loss-v1 (0x11a2ca90)
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Remote Config API Initializing
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Remote Config API Initialized
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

2020-08-23 21:28:52.923641-0400 v1[1175:273744] FCM: registration token received, but no listener set yet - cached the token.
FCM: registration token received, but no listener set yet - cached the token. 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Registering Crashlytics exception handlers
Firebase.Crashlytics.ExceptionHandler:Register()
Firebase.Crashlytics.Crashlytics:Initialize()
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
Firebase.FirebaseApp:InitializeCrashlyticsIfPresent()
System.Func`1:Invoke()
Firebase.<Run>c__AnonStorey0`1:<>m__0()
System.Action:Invoke()
Firebase.ExceptionAggregator:Wrap(Action)
Firebase.Dispatcher:PollJobs()
Firebase.Platform.FirebaseHandler:Update()
 
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

Firebase initialized
System.Action`1:Invoke(T)
System.Threading.Tasks.Task:Execute()
System.Threading.ContextCallback:Invoke(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&)
System.Threading.Tasks.Task:ExecuteEntry(Boolean)
System.Threading.ThreadPoolWorkQueue:Dispatch()

Probé las aplicaciones de muestra para Analytics y Crashlytics (por separado). Recibo el mismo error en ambos.

¿Alguien sabe lo que estoy haciendo mal?

0
Evorlor 24 ago. 2020 a las 03:52

1 respuesta

La mejor respuesta

Creo que el mensaje de error que está viendo es falso. Consulte este comentario en GitHub, por ejemplo.

A menos que vea alguna funcionalidad rota, todo se ve bien (más abajo en sus registros hay un Firebase initialized y mensajes sobre la recepción correcta de tokens FCM).

A veces tienes problemas al usar ContinueWith en lugar de ContinueWithOnMainThread (consulta este entrada de blog o vídeo) que podría ofuscar algunos registros o causar inestabilidad. Por lo que puedo ver, no se está encontrando con ese problema, pero vale la pena cambiarlo si ContinueWith no fue una decisión consciente.

0
Patrick Martin 24 ago. 2020 a las 22:00