Firebase.Auth instance is always null?

joellinderjoellinder SEMember ✭✭

Hi, I'm developing a android app with xamarin and i'm trying integrate firebase's auth system with the firebase.auth nuget package from xamarin. However whenever i try to access the FirebaseAuth.Instance Property i get this exception: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.myapp.droid. Make sure to call FirebaseApp.initializeApp(Context) first.

I've tried calling FirebaseApp.InitializeApp in my Main Activity but i still get the same result. Anyone knows how to solve this?

Answers

  • AlbertKAlbertK MYMember ✭✭✭

    It's a big bad bug. For work around please refer to

    https://bugzilla.xamarin.com/show_bug.cgi?id=56108

    Add this to your .csproj file

        <Target Name="RemoveGoogleServicesJsonStampFiles" BeforeTargets="BeforeBuild">
            <Delete Files="$(IntermediateOutputPath)\ProcessGoogleServicesJson.stamp" />
          </Target>
    
  • joellinderjoellinder SEMember ✭✭

    @AlbertK said:
    It's a big bad bug. For work around please refer to

    https://bugzilla.xamarin.com/show_bug.cgi?id=56108

    Add this to your .csproj file

        <Target Name="RemoveGoogleServicesJsonStampFiles" BeforeTargets="BeforeBuild">
            <Delete Files="$(IntermediateOutputPath)\ProcessGoogleServicesJson.stamp" />
          </Target>
    

    Thank you for your reply. I added the target to my csproj file but I'm still getting the exception.

    07-22 12:08:31.031 E/mono-rt (28013): [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.motza.droid. Make sure to call FirebaseApp.initializeApp(Context) first.
    07-22 12:08:31.031 E/mono-rt (28013): --- End of managed Java.Lang.IllegalStateException stack trace ---
    07-22 12:08:31.031 E/mono-rt (28013): java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.motza.droid. Make sure to call FirebaseApp.initializeApp(Context) first.
    07-22 12:08:31.031 E/mono-rt (28013): at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
    07-22 12:08:31.031 E/mono-rt (28013): at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
    07-22 12:08:31.031 E/mono-rt (28013): at mono.java.lang.RunnableImplementor.n_run(Native Method)
    07-22 12:08:31.031 E/mono-rt (28013): at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
    07-22 12:08:31.031 E/mono-rt (28013): at android.app.Activity.runOnUiThread(Activity.java:6030)
    07-22 12:08:31.031 E/mono-rt (28013): at mono.java.lang.RunnableImplementor.n_run(Native Method)
    07-22 12:08:31.031 E/mono-rt (28013): at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
    07-22 12:08:31.031 E/mono-rt (28013): at android.os.Handler.handleCallback(Handler.java:751)
    07-22 12:08:31.031 E/mono-rt (28013): at android.os.Handler.dispatchMessage(Handler.java:95)
    07-22 12:08:31.031 E/mono-rt (28013): at android.os.Looper.loop(Looper.java:154)
    07-22 12:08:31.031 E/mono-rt (28013): at android.app.ActivityThread.main(ActivityThread.java:6692)
    07-22 12:08:31.031 E/mono-rt (28013): at java.lang.reflect.Method.invoke(Native Method)
    07-22 12:08:31.031 E/mono-rt (28013): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    07-22 12:08:31.031 E/mono-rt (28013): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

  • ajoharajohar INMember ✭✭

    See if you can use Xamarin.Auth. I had a better time with that than Firebase, and the implementation is simple.

Sign In or Register to comment.