Firebase App初始化应用__FIRAPP_DEFAULT(默认为1)

时间:2018-05-25 09:29:45

标签: android firebase unity3d firebase-authentication

当我以统一的方式运行游戏时,会出现一条调试消息:

Firebase App initializing app __FIRAPP_DEFAULT (default 1).
UnityEngine.Debug:Log(Object)
Firebase.Platform.FirebaseLogger:LogMessage(PlatformLogLevel, String)
Firebase.FirebaseApp:LogMessage(LogLevel, String)
Firebase.AppUtilPINVOKE:FirebaseApp_CreateInternal__SWIG_0()
Firebase.FirebaseApp:CreateInternal()
Firebase.FirebaseApp:<Create>m__0()
Firebase.FirebaseApp:CreateAndTrack(CreateDelegate, FirebaseApp)
Firebase.FirebaseApp:Create()
Firebase.FirebaseApp:get_DefaultInstance()
Firebase.Auth.FirebaseAuth:get_DefaultInstance()
EmailPassword:Start() (at Assets/Examples/Auth/EmailPassword.cs:19)

这是EmailPassword.cs文件代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Firebase.Auth;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System;

public class EmailPassword : MonoBehaviour
{

private FirebaseAuth auth;
public InputField UserNameInput, PasswordInput;
public Button SignupButton, LoginButton;
public Text ErrorText;

void Start()
{
    auth = FirebaseAuth.DefaultInstance;
    //Just an example to save typing in the login form
    UserNameInput.text = "demofirebase@gmail.com";
    PasswordInput.text = "abcdefgh";

    SignupButton.onClick.AddListener(() => Signup(UserNameInput.text, PasswordInput.text));
    LoginButton.onClick.AddListener(() => Login(UserNameInput.text, PasswordInput.text));
}


public void Signup(string email, string password)
{
    if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
    {
        //Error handling
        return;
    }

    auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
    {
        if (task.IsCanceled)
        {
            Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
            return;
        }
        if (task.IsFaulted)
        {
            Debug.LogError("CreateUserWithEmailAndPasswordAsync error: " + task.Exception);
            if (task.Exception.InnerExceptions.Count > 0)
                UpdateErrorMessage(task.Exception.InnerExceptions[0].Message);
            return;
        }

        FirebaseUser newUser = task.Result; // Firebase user has been created.
        Debug.LogFormat("Firebase user created successfully: {0} ({1})",
            newUser.DisplayName, newUser.UserId);
        UpdateErrorMessage("Signup Success");
    });
}

private void UpdateErrorMessage(string message)
{
    ErrorText.text = message;
    Invoke("ClearErrorMessage", 3);
}

void ClearErrorMessage()
{
    ErrorText.text = "";
}
public void Login(string email, string password)
{
    auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
    {
        if (task.IsCanceled)
        {
            Debug.LogError("SignInWithEmailAndPasswordAsync canceled.");
            return;
        }
        if (task.IsFaulted)
        {
            Debug.LogError("SignInWithEmailAndPasswordAsync error: " + task.Exception);
            if (task.Exception.InnerExceptions.Count > 0)
                UpdateErrorMessage(task.Exception.InnerExceptions[0].Message);
            return;
        }

        FirebaseUser user = task.Result;
        Debug.LogFormat("User signed in successfully: {0} ({1})",
            user.DisplayName, user.UserId);

        PlayerPrefs.SetString("LoginUser", user != null ? user.Email : "Unknown");
        SceneManager.LoadScene("LoginResults");
    });
}
}

我从这里https://firebase.google.com/docs/unity/setup下载了Firebase Unity SDK,所以我认为我有最新版本。 当我尝试 Resolve Force Resolve 按钮时,会出现错误:

Resolving to Android package directory Assets\Plugins\Android instead of the requested target directory Assets/Plugins/Android

Is Assets\Plugins\Android in a different case to Assets/Plugins/Android ?

UnityEngine.Debug:LogWarning(Object)
Google.Logger:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:Log(String, LogLevel)
GooglePlayServices.SettingsDialog:ValidatePackageDir(String)
GooglePlayServices.SettingsDialog:get_PackageDir()
GooglePlayServices.PlayServicesResolver:OnPostprocessAllAssets(String[], String[], String[], String[])
UnityEditor.AssetDatabase:Refresh()
GooglePlayServices.PlayServicesResolver:DeleteLabeledAssets()
GooglePlayServices.PlayServicesResolver:ResolveUnsafe(Action`1, Boolean)
GooglePlayServices.<Resolve>c__AnonStorey11:<>m__19()
GooglePlayServices.PlayServicesResolver:ExecuteNextResolveJob()
GooglePlayServices.PlayServicesResolver:Resolve(Action, Boolean, Action`1)
GooglePlayServices.PlayServicesResolver:ExecuteMenuResolve(Boolean)
GooglePlayServices.PlayServicesResolver:MenuForceResolve()

有任何帮助解决问题吗?

1 个答案:

答案 0 :(得分:0)

您已使用正斜杠/而不是向后斜杠\配置SDK,这是您的操作系统的相应目录标记。只需将SDK目录更改为Assets\Plugins\Android