Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App crashes after FirebaseAuth.DefaultInstance

I use FireBase authentication with a simple function that signs up a new user, it works great on the Unity Editor, but when I build it on my Android, it crashes the second it tries to read this line- FirebaseAuth auth = FirebaseAuth.DefaultInstance

This is the error I get before it crashes-

Java class com/google/firebase/auth/FirebaseAuthWebException not found. Please verify the AAR which contains the com/google/firebase/auth/FirebaseAuthWebException class is included in your app.

  1. Why do I even get the Firebase-AuthWeb-Exception ?
  2. Why can't it find that exception? (I tried to resolve jar files, and to re-import auth SDK but it didn't solve the issue

My app is simple- there's a SignUp button that calls this function-

 public void SignUp()
 {
    FirebaseAuth auth = FirebaseAuth.DefaultInstance;  //The error is after this line

    auth.CreateUserWithEmailAndPasswordAsync(email.text, password.text).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);
       // SignInWithVerification();
    });


}
  • Unity- 2108.2.12f1
  • Build system- Gradle
  • Firebase unity sdk 5.4.0 dotnet3
like image 723
SHAI Avatar asked Feb 06 '26 00:02

SHAI


2 Answers

Okay, I managed to solve this. For me it never crashed, but just because I got this error I assumed it was setting the Auth DefaultInstance as null (while it actually worked).

For clarification, I am using Firebase Auth, Firebase Database, Google Play Services.

The error went away when I downgraded to Firebase 5.2.1. I am not sure why this error makes your app crash, maybe it is something else? You could try removing the line and see if it still crashes.

When I realised that this error doesn't actually harm anything I upgraded back to 5.4.0 and even though I get this error, everything works beyond that.

like image 52
Kaarel Reinvars Avatar answered Feb 09 '26 07:02

Kaarel Reinvars


I finally fixed it! It was a problem with the dependencies but was impossible to solve, even though I tried Androd-resolve so many times.

-I removed all Firebase files (make sure you remove everything) -I removed Library folder (under project folder) not sure if it's necessary -I removed AndroidResolverDependencies (under projectsettings folder) -I removed unity folder in C:\Users*\AppData\Local and C:\Users***\AppData\Roaming
-Installed the Firebase package again -Android resolve

That's it. Nobody could help me with it so I removed EVERYTHING! *Save a backup of everything before you try my solution

like image 31
SHAI Avatar answered Feb 09 '26 07:02

SHAI



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!