Search Unity

System.AggregateException Firebase

Discussion in 'Formats & External Tools' started by Benge007, Jul 28, 2018.

  1. Benge007

    Benge007

    Joined:
    Feb 1, 2014
    Posts:
    6
    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.<ContinueWith>c__AnonStorey0:<>m__0(Task)

    System.Threading.Tasks.<ContinueWith>c__AnonStorey2:<>m__0(Task)

    System.Threading.Tasks.<ContinueWith>c__AnonStorey1:<>m__0()

    System.Threading.Tasks.Task:<immediateExecutor>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.TaskCompletionSourceCompat`1:SetException(TaskCompletionSource`1, AggregateException)

    System.Threading.Tasks.<ContinueWith>c__AnonStorey0:<>m__0(Task)

    System.Threading.Tasks.<ContinueWith>c__AnonStorey2:<>m__0(Task)

    System.Threading.Tasks.<ContinueWith>c__AnonStorey1:<>m__0()

    System.Threading.Tasks.Task:<immediateExecutor>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.<GetTask>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:<Start>m__0(Task`1) (at Assets/TestSignUpScript.cs:37)
    System.Threading.Tasks.TaskCompletionSource`1:SetException(AggregateException)
    Firebase.Internal.TaskCompletionSourceCompat`1:SetExceptionInternal(TaskCompletionSource`1, AggregateException)
    Firebase.Internal.TaskCompletionSourceCompat`1:SetException(TaskCompletionSource`1, AggregateException)
    Firebase.Auth.FirebaseAuth:CompleteFirebaseUserTask(Task`1, TaskCompletionSource`1)
    Firebase.Auth.<CreateUserWithEmailAndPasswordAsync>c__AnonStorey8:<>m__0(Task`1)
    System.Threading.Tasks.TaskCompletionSource`1:SetException(Exception)
    Firebase.Auth.<GetTask>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.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Firebase;
    5. using Firebase.Auth;
    6. using Firebase.Database;
    7. using UnityEngine.Networking;
    8.  
    9. public class TestSignUpScript : MonoBehaviour {
    10.     private Firebase.Auth.FirebaseAuth auth;
    11.     // Use this for initialization
    12.    
    13.     void Start()
    14.     {
    15.  
    16.         var email = "email@gmail.com";
    17.         var password = "tester123";
    18.         auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
    19.         auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
    20.             if (task.IsCanceled)
    21.             {
    22.                 Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
    23.                 return;
    24.             }
    25.             if (task.IsFaulted)
    26.             {
    27.                 Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + task.Exception);
    28.                 return;
    29.             }
    30.  
    31.             // Firebase user has been created.
    32.             Firebase.Auth.FirebaseUser newUser = task.Result;
    33.             Debug.LogFormat("Firebase user created successfully: {0} ({1})",
    34.                 newUser.DisplayName, newUser.UserId);
    35.         });
    36.         auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task => {
    37.             if (task.IsCanceled)
    38.             {
    39.                 Debug.LogError("SignInWithEmailAndPasswordAsync was canceled.");
    40.                 return;
    41.             }
    42.             if (task.IsFaulted)
    43.             {
    44.                 Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception);
    45.                 return;
    46.             }
    47.  
    48.             Firebase.Auth.FirebaseUser newUser = task.Result;
    49.             Debug.LogFormat("User signed in successfully: {0} ({1})",
    50.                 newUser.DisplayName, newUser.UserId);
    51.         });
    52.     }
    53.    
    54.     // Update is called once per frame
    55.     void Update () {
    56.        
    57.     }
    58.  
    59.     Firebase.Auth.FirebaseUser user;
    60.     // Handle initialization of the necessary firebase modules:
    61.     void InitializeFirebase()
    62.     {
    63.         Debug.Log("Setting up Firebase Auth");
    64.         auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
    65.         auth.StateChanged += AuthStateChanged;
    66.         AuthStateChanged(this, null);
    67.     }
    68.  
    69.     // Track state changes of the auth object.
    70.     void AuthStateChanged(object sender, System.EventArgs eventArgs)
    71.     {
    72.         if (auth.CurrentUser != user)
    73.         {
    74.             bool signedIn = user != auth.CurrentUser && auth.CurrentUser != null;
    75.             if (!signedIn && user != null)
    76.             {
    77.                 Debug.Log("Signed out " + user.UserId);
    78.             }
    79.             user = auth.CurrentUser;
    80.             if (signedIn)
    81.             {
    82.                 Debug.Log("Signed in " + user.UserId);
    83.             }
    84.         }
    85.     }
    86. }
     
  2. c-pellet

    c-pellet

    Joined:
    Mar 24, 2018
    Posts:
    3
    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...-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.
     
  3. jsfpw

    jsfpw

    Joined:
    Nov 2, 2017
    Posts:
    3
    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.
     
  4. jsfpw

    jsfpw

    Joined:
    Nov 2, 2017
    Posts:
    3
    I guess they updated the SDK, because i'm able to test auth in editor and desktop build on my current project.
     
  5. Rainking

    Rainking

    Joined:
    Jun 10, 2013
    Posts:
    41
    I see the problem calling the firebase cloud functions. Auth runs without a problem in the editor.
     
  6. ashum2802

    ashum2802

    Joined:
    Feb 6, 2019
    Posts:
    1
    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.
     
  7. okandemirkaya

    okandemirkaya

    Joined:
    Oct 27, 2020
    Posts:
    2
    I also had the same problem. If you update the google-services.json file, the problem solved.
     
    pauloramos_unity likes this.
  8. kingvivek1010

    kingvivek1010

    Joined:
    Feb 17, 2022
    Posts:
    1
    Just go to firebase console and in authentication enable the email login option then you will be ready to go...
     
    l0calhost likes this.
  9. pauloramos_unity

    pauloramos_unity

    Joined:
    Oct 3, 2022
    Posts:
    1
    It worked for me.