我的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");
}
Run Code Online (Sandbox Code Playgroud)
所以应用程序构建和运行没有崩溃.但通过adb logcat -s Unity我可以看到以下内容: …