Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.bottomnav

I made the basic version of my app which included Firebase Authentication and before I connected the app with firebase, I tested the app in the Android Emulator. I got the following error and then I fixed few things on my own.
-connected the firebase
-added the dependency
classpath 'com.google.gms:google-services:4.2.0'

Still the following error is encountered -

/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.bottomnav, PID: 2049
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bottomnav/com.example.bottomnav.login}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.bottomnav. Make sure to call FirebaseApp.initializeApp(Context) first.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
     Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.bottomnav. Make sure to call FirebaseApp.initializeApp(Context) first.
        at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@19.3.0:184)
        at com.google.firebase.auth.FirebaseAuth.getInstance(com.google.firebase:firebase-auth@@19.3.1:1)
        at com.example.bottomnav.login.onCreate(login.java:40)
        at android.app.Activity.performCreate(Activity.java:8000)
        at android.app.Activity.performCreate(Activity.java:7984)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)

I have used the Firebase tool in my earlier projects and I am under the impression that using the in-built firebase tool within the Android Studio does everything automatically. So, is there any step that I may have skipped?

like image 211
Saheel Sapovadia Avatar asked Sep 03 '25 07:09

Saheel Sapovadia


2 Answers

for me, the issue was using google service plugin version 4.3.9. just change

        classpath 'com.google.gms:google-services:4.3.9'  

to

       classpath 'com.google.gms:google-services:4.3.8'  
like image 148
APP Bird Avatar answered Sep 04 '25 19:09

APP Bird


You probably did not add the google-services plugin to your build.gradle. It's more than just a dependency. According to the documentation, you also have to add:

apply plugin: 'com.google.gms.google-services'
like image 24
Doug Stevenson Avatar answered Sep 04 '25 21:09

Doug Stevenson