【发布时间】:2017-04-28 09:57:00
【问题描述】:
我在 Unity 项目中遇到了 Firebase 问题。 Firebase SDK 已导入项目中,构建完成,在此过程中没有错误。
SHA-1 密钥是使用 keytool 生成的,并已添加到控制台中的 Firebase 项目中。
google-services.json 也被添加到 Assets 文件夹中。
初始化 Firebase 的简单脚本:
DependencyStatus dependencyStatus = DependencyStatus.UnavailableOther;
// Use this for initialization
void Start ()
{
Debug.Log ("Start FireBase");
dependencyStatus = FirebaseApp.CheckDependencies();
if (dependencyStatus != DependencyStatus.Available)
{
FirebaseApp.FixDependenciesAsync().ContinueWith(task =>
{
dependencyStatus = FirebaseApp.CheckDependencies();
if (dependencyStatus == DependencyStatus.Available)
{
InitializeFirebase();
}
else
{
Debug.LogError("Could not resolve all Firebase dependencies: " + dependencyStatus);
}
});
}
else
{
InitializeFirebase();
}
}
void InitializeFirebase()
{
FirebaseAnalytic.Instance().setAnalyticsCollectionEnabled(true);
FirebaseAnalytic.Instance().setUserProperty(FirebaseAnalytics.UserPropertySignUpMethod, "Google");
FirebaseAnalytic.Instance().setUserId(SystemInfo.deviceUniqueIdentifier);
FirebaseAnalytic.Instance().logEvent("LogIn", FirebaseAnalytics.EventLogin);
Debug.Log ("FirebaseAnalytics Logined");
}
因此应用程序构建和运行时不会崩溃。但是通过adb logcat -s Unity我可以看到以下内容:
I/Unity (27030): Start FireBase
I/Unity (27030): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
I/Unity (27030):
I/Unity (27030): Firebase App initializing app com.boldstatementproductions.mcpro (default 1).
I/Unity (27030): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
I/Unity (27030):
W/Unity (27030): Callback module already shut down
W/Unity (27030): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
E/Unity (27030): java_app
E/Unity (27030): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
I/Unity (27030): Firebase App initializing app com.boldstatementproductions.mcpro (default 1).
I/Unity (27030): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
W/Unity (27030): Callback module already shut down
W/Unity (27030): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
E/Unity (27030): java_app
E/Unity (27030): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
I/Unity (27030): InitializationException: Failed to initialize the default Firebase App.
I/Unity (27030): at Firebase.FirebaseApp.CreateAndTrack (Firebase.CreateDelegate createDelegate) [0x00000] in <filename unknown>:0
I/Unity (27030): at Firebase.FirebaseApp.Create () [0x00000] in <filename unknown>:0
I/Unity (27030): at Firebase.FirebaseApp.get_DefaultInstance () [0x00000] in <filename unknown>:0
I/Unity (27030): at Firebase.Analytics.FirebaseAnalytics..cctor () [0x00000] in <filename unknown>:0
I/Unity (27030): Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Firebase.Analytics.FirebaseAnalytics
I/Unity (27030): at FirebaseDependencyResolver.InitializeFirebase () [0x00000] in <filename unknown>:0
I/Unity (27030): at FirebaseDependencyResolver.Start () [0x00000] in <filename unknown>:0
I/Unity (27030): (Filename: Line: -1)
谷歌搜索这些消息并没有太大帮助。我错过了什么? 我一步一步按照 Unity 的 Firebase 设置教程进行操作。这个错误已经把我吓了一个星期了!
【问题讨论】:
-
您是为 iOS 还是 Android 构建?
-
我们在生产中也收到了数千个类似的错误报告......在 Android 上
-
@adbitx for android。问题包含来自应用程序启动阶段的 adb(Android 调试桥)的日志。
-
这里是 Firebase 工程师。你有机会发布完整的日志吗?如果您可以通过我们的支持门户firebase.google.com/support 分享一个演示问题的项目,那就更好了?我一直在尝试重现问题(破坏捆绑 ID、删除配置文件、删除随机 Android AAR)并且没有重现它。
-
@stewartmiles 实际上,这就是所有日志。我已经向支持人员报告了这个问题。不幸的是,我不能分享项目。我会尝试将它放在测试项目中,但我猜情况会有所不同。
标签: c# firebase unity3d firebase-analytics