System.AggregateException Firebase

In need of some help with an error. Below is the error produced when the scenes built in iOS whilst using Firebases Auth.

CreateUserWithEmailAndPasswordAsync encountered an error: System.AggregateException: Exception of type 'System.AggregateException' was thrown.

-----------------

Firebase.FirebaseException: An internal error has occurred, print and inspect the error details for more information.

System.Threading.Tasks.c_AnonStorey0:<>m_0(Task)

System.Threading.Tasks.c_AnonStorey2:<>m_0(Task)

System.Threading.Tasks.c_AnonStorey1:<>m_0()

System.Threading.Tasks.Task:m__1(Action)

System.Threading.Tasks.Task`1:RunContinuations()

System.Threading.Tasks.Task`1:TrySetException(AggregateException)

System.Threading.Tasks.TaskCompletionSource`1:SetException(AggregateException)

Firebase.Internal.TaskCompletionSourceCompat1:SetException(TaskCompletionSource1, AggregateException)

System.Threading.Tasks.c_AnonStorey0:<>m_0(Task)

System.Threading.Tasks.c_AnonStorey2:<>m_0(Task)

System.Threading.Tasks.c_AnonStorey1:<>m_0()

System.Threading.Tasks.Task:m__1(Action)

System.Threading.Tasks.Task`1:RunContinuations()

System.Threading.Tasks.Task`1:TrySetException(AggregateException)

System.Threading.Tasks.TaskCompletionSource`1:SetException(Exception)

Firebase.Auth.c_AnonStorey0:<>m_0()

Firebase.Auth.Future_User:SWIG_CompletionDispatcher(Int32)

Firebase.AppUtil:PollCallbacks()

Firebase.Platform.FirebaseHandler:Update()

Now here is it when it is just run on the editor.

CreateUserWithEmailAndPasswordAsync encountered an error: System.AggregateException: Exception of type 'System.AggregateException' was thrown.
-----------------
Firebase.FirebaseException: An internal error has occurred.
UnityEngine.Debug:LogError(Object)
TestSignUpScript:m__0(Task`1) (at Assets/TestSignUpScript.cs:37)
System.Threading.Tasks.TaskCompletionSource`1:SetException(AggregateException)
Firebase.Internal.TaskCompletionSourceCompat1:SetExceptionInternal(TaskCompletionSource1, AggregateException)
Firebase.Internal.TaskCompletionSourceCompat1:SetException(TaskCompletionSource1, AggregateException)
Firebase.Auth.FirebaseAuth:CompleteFirebaseUserTask(Task1, TaskCompletionSource1)
Firebase.Auth.c_AnonStorey8:<>m_0(Task`1)
System.Threading.Tasks.TaskCompletionSource`1:SetException(Exception)
Firebase.Auth.c_AnonStorey0:<>m_0()
Firebase.Auth.Future_User:SWIG_CompletionDispatcher(Int32)
Firebase.AppUtilPINVOKE:PollCallbacks()
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseAppUtils:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
Firebase.Platform.FirebaseMonoBehaviour:Update()

I'm struggling to solve this issue. On firebase console, the authentication is enabled. All of the dependencies are installed. An SHA-1 Certificate is issued for the Android version too. Firebase does initialise as well.

I've managed to create and sign into an account before but not idea why its not doing so now.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Firebase;
using Firebase.Auth;
using Firebase.Database;
using UnityEngine.Networking;

public class TestSignUpScript : MonoBehaviour {
    private Firebase.Auth.FirebaseAuth auth;
    // Use this for initialization

    void Start()
    {

        var email = "email@gmail.com";
        var password = "tester123";
        auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
        auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + task.Exception);
                return;
            }

            // Firebase user has been created.
            Firebase.Auth.FirebaseUser newUser = task.Result;
            Debug.LogFormat("Firebase user created successfully: {0} ({1})",
                newUser.DisplayName, newUser.UserId);
        });
        auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInWithEmailAndPasswordAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception);
                return;
            }

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

    // Update is called once per frame
    void Update () {

    }

    Firebase.Auth.FirebaseUser user;
    // Handle initialization of the necessary firebase modules:
    void InitializeFirebase()
    {
        Debug.Log("Setting up Firebase Auth");
        auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
        auth.StateChanged += AuthStateChanged;
        AuthStateChanged(this, null);
    }

    // Track state changes of the auth object.
    void AuthStateChanged(object sender, System.EventArgs eventArgs)
    {
        if (auth.CurrentUser != user)
        {
            bool signedIn = user != auth.CurrentUser && auth.CurrentUser != null;
            if (!signedIn && user != null)
            {
                Debug.Log("Signed out " + user.UserId);
            }
            user = auth.CurrentUser;
            if (signedIn)
            {
                Debug.Log("Signed in " + user.UserId);
            }
        }
    }
}

I've also encountered this error a few months ago and it appears Firebase does not support Auth services at build : https://stackoverflow.com/questions/41788413/using-firebase-authentication-with-unity-on-standalone-game -> Standalone builds aren't currently supported by firebase-unity which is a real pain. I'd suggest getting in touch with firebase via the google groups or whatever to register your interest in standalone support.

Got the same error few weeks ago, but I was targeting android, not IOS. importing the google-services.json in the root assets folder resolved the problem.

[quote=“c-pellet”, post:2, topic: 709666]
I’ve also encountered this error a few months ago and it appears Firebase does not support Auth services at build : https://stackoverflow.com/questions/41788413/using-firebase-authentication-with-unity-on-standalone-game → Standalone builds aren’t currently supported by firebase-unity which is a real pain. I’d suggest getting in touch with firebase via the google groups or whatever to register your interest in standalone support.
[/quote]
I guess they updated the SDK, because i’m able to test auth in editor and desktop build on my current project.

I see the problem calling the firebase cloud functions. Auth runs without a problem in the editor.

[quote=“jsfpw”, post:4, topic: 709666]
I guess they updated the SDK, because i’m able to test auth in editor and desktop build on my current project.
[/quote]

Bro can You plz help by posting your signin script Because I am able to register users but the users are not able to sign in again after signing out . Help me Someone I am Stucked.

I also had the same problem. If you update the google-services.json file, the problem solved.

1 Like

Just go to firebase console and in authentication enable the email login option then you will be ready to go...

1 Like


It worked for me.