-1

I have added two android apps in my firebase project, but the newly added app keeps crashing with following error:

Caused by: java.lang.IllegalStateException: Default FirebaseApp is not
initialized in this process com.x.y. Make sure to call
FirebaseApp.initializeApp(Context) first.

Note : I tried adding FirebaseApp.initializeApp(Context) this too, but did not work.

Dependency added in gradle file:

{ ..... 


    def firebase_version = "16.0.1"

    implementation "com.google.firebase:firebase-core:$firebase_version"
    implementation "com.google.firebase:firebase-auth:$firebase_version"
    implementation "com.google.firebase:firebase-database:$firebase_version"
    implementation "com.google.firebase:firebase-analytics:$firebase_version"
    implementation "com.google.firebase:firebase-storage:$firebase_version"

}
rcde0
  • 4,192
  • 3
  • 21
  • 31
  • can you please add your app level build.gradle file? – Gregorio Palamà Aug 31 '18 at 12:21
  • @GregorioPalamà, I've added the dependencies used. – rcde0 Aug 31 '18 at 12:29
  • thanks. Did you apply the google services plugin in your app level build.gradle? That's required, to make Firebase works – Gregorio Palamà Aug 31 '18 at 12:31
  • Yes @GregorioPalamà – rcde0 Aug 31 '18 at 12:55
  • @rcde0 Here: https://firebase.google.com/docs/android/setup try adding latest versions *to each dependencies separately*. If it didn't solve the issue, paste your `Activity` code. – ʍѳђઽ૯ท Aug 31 '18 at 13:57
  • You app shouldn't build with those dependencies. Ever since version 15 of the client libraries, each product does not share the same versions. They are released independently now. https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html – Doug Stevenson Aug 31 '18 at 15:22
  • @DougStevenson, thanks for the info. I'll not be using the "same version number" for firebase dependencies. However my app builds with the above listed dependencies. – rcde0 Sep 02 '18 at 06:29

2 Answers2

1

For me none of the solution worked that were given any where. Only this worked. Just had to download grade my google services from 4.1.0 to 4.0.0 Change it in both gradle files.

dependencies {
    classpath 'com.google.gms:google-services:4.0.0'
    /*classpath 'com.google.gms:google-services:4.1.0' <-- this was the problem */
}

So if you have updated the google services, just try to downgrade or change to an older version. Hope it helps

Ammar Bukhari
  • 2,082
  • 2
  • 16
  • 16
0

Default FirebaseApp is not initialized in this process com.x.y. Make sure to call FirebaseApp.initializeApp(Context) first.

It's pretty clear that you didn't initialized Firebase in onCreate method.

Add:

FirebaseApp.initializeApp(Youractivity.this)

Inside onCreate method.


Although, both apps will need their needed dependencies which you gotta add them in build.gradle also.

ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
  • It will surely fix the error, but this is not the right solution, in my opinion. The initialization is something that Firebase does on its own, so the error is just telling us that something is not working as expected – Gregorio Palamà Aug 31 '18 at 12:22
  • Well, let's fix the mentioned issue first since the OP said that he/she's trying to add two apps in there. It will surely be more needed dependencies or errors which i have edited the answer for the **current issue**. – ʍѳђઽ૯ท Aug 31 '18 at 12:24