Google Firebase Auth Error

Hi!
I’m trying to make a login system with Firebase but i’m getting these errors:

NullReferenceException: Object reference not set to an instance of an object
AuthManager+d__9.MoveNext () (at Assets/Kódok/AuthManager.cs:49)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <0dc26211fc6f43128da1d70c2c3a8abc>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
AuthManager:Login() (at Assets/Kódok/AuthManager.cs:44)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)

Unable to load Firebase app options ([C:/Users/(My Username)/Documents/Unity/Matek/Assets/StreamingAssets\google-services-desktop.json, C:/Users/(My Username/Documents/Unity/Matek/Assets/StreamingAssets\google-services.json] are missing or malformed)
UnityEngine.Debug:LogError (object)
Firebase.Platform.FirebaseLogger:LogMessage (Firebase.Platform.PlatformLogLevel,string) (at Z:/tmp/tmp.lhQd7HKjFZ/firebase/app/client/unity/src/Unity/FirebaseLogger.cs:95)
Firebase.LogUtil:LogMessage (Firebase.LogLevel,string) (at Z:/tmp/tmp.0D8YKhldYk/firebase/app/client/unity/proxy/LogUtil.cs:69)
Firebase.LogUtil:LogMessageFromCallback (Firebase.LogLevel,string) (at Z:/tmp/tmp.0D8YKhldYk/firebase/app/client/unity/proxy/LogUtil.cs:77)
Firebase.AppUtil:PollCallbacks () (at Z:/tmp/tmp.0D8YKhldYk/firebase/app/client/unity/proxy/AppUtil.cs:32)
Firebase.Platform.FirebaseAppUtils:PollCallbacks () (at Z:/tmp/tmp.0D8YKhldYk/firebase/app/client/unity/proxy/FirebaseAppUtils.cs:33)
Firebase.Platform.FirebaseHandler:Update () (at Z:/tmp/tmp.lhQd7HKjFZ/firebase/app/client/unity/src/Unity/FirebaseHandler.cs:208)
Firebase.Platform.FirebaseMonoBehaviour:Update () (at Z:/tmp/tmp.lhQd7HKjFZ/firebase/app/client/unity/src/Unity/FirebaseMonoBehaviour.cs:45)

Assembly ‘Assets/Firebase/Editor/Firebase.Editor.dll’ will not be loaded due to errors:
Reference has errors ‘Google.IOSResolver’.

Assembly ‘Assets/ExternalDependencyManager/Editor/Google.IOSResolver_v1.2.166.dll’ will not be loaded due to errors:
Assembly name ‘Google.IOSResolver’ does not match file name ‘Google.IOSResolver_v1.2.166’

And here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Firebase;
using Firebase.Auth;
using TMPro;

public class AuthManager : MonoBehaviour
{
    [Header("Firebase")]
    [SerializeField] private DependencyStatus dependencyStatus;
    public FirebaseAuth auth;
    public FirebaseUser User;

    [Header("Bejelentkezés")]
    [SerializeField] private TMP_InputField email;
    [SerializeField] private TMP_InputField jelszo;
    [SerializeField] private TMP_Text hiba;

    private void Awake()
    {
        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
        {
            dependencyStatus = task.Result;
            if (dependencyStatus == DependencyStatus.Available)
            {
                InitializeFirebase();
            }
            else
            {
                Debug.LogError("Could not resolve all Firebase dependencies: " + dependencyStatus);
            }
        });
    }

    private void InitializeFirebase()
    {
        Debug.Log("Setting up Firebase Auth");
        auth = FirebaseAuth.DefaultInstance;
    }

    public void Login()
    {
        StartCoroutine(Login(email.text, jelszo.text));
    }

    private IEnumerator Login(string _email, string _jelszo)
    {
        var LoginTask = auth.SignInWithEmailAndPasswordAsync(_email, _jelszo);

        yield return new WaitUntil(predicate: () => LoginTask.IsCompleted);

        if (LoginTask.Exception != null)
        {
            Debug.LogWarning(message: $"Failed to register task with {LoginTask.Exception}");
            FirebaseException firebaseException = LoginTask.Exception.GetBaseException() as FirebaseException;
            AuthError errorCode = (AuthError)firebaseException.ErrorCode;

            string message = "A bejelentkezés nem sikerült!";
            switch (errorCode)
            {
                case AuthError.MissingEmail:
                    message = "Hiányzó Email!";
                    break;
                case AuthError.MissingPassword:
                    message = "Hiányzó Jelszó!";
                    break;
                case AuthError.WrongPassword:
                    message = "Hibás Jelszó!";
                    break;
                case AuthError.InvalidEmail:
                    message = "Hibás Email!";
                    break;
                case AuthError.UserNotFound:
                    message = "Ez a fiók nem létezik!";
                    break;
            }
            hiba.text = message;
        }
        else
        {
            User = LoginTask.Result;
            Debug.LogFormat("Sikeresen bejelentkezett: {0} ({1})", User.DisplayName, User.Email);
            hiba.text = "";
        }
    }
}
1 Like

Hi! Solved the problem?