Skip to content Skip to sidebar Skip to footer

Make Sure To Call Firebaseapp.initializeapp(context) First

It might be really same with other questions already but I don't really know what's wrong in here. Thanks in advance for the help. build.gradle (project) // Top-level build

Solution 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

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.0-alpha08'
    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 someone else.

Solution 2:

According to the docs:

As said in the docs:

Any FirebaseApp initialization must occur only in the main process of the app. Use of Firebase in processes other than the main process is not supported and will likely cause problems related to resource contention.

you need to initialize it not in the activity.

add an application class to your manifest example:

      <applicaton
       android:name="MyApplication"

then do this:

publicclassMyApplicationextendsApplication {
  @OverridepublicvoidonCreate() {
    super.onCreate();
   FirebaseApp.initializeApp(this);
}

and remove the initialization from the activity. You need to initialize it in the application class which is the base class.

Edit(about application):

Base class for maintaining global application state. You can provide your own implementation by creating a subclass and specifying the fully-qualified name of this subclass as the "android:name" attribute in your AndroidManifest.xml's tag. The Application class, or your subclass of the Application class, is instantiated before any other class when the process for your application/package is created.

Useful link: https://developer.android.com/reference/android/app/Application.html

Solution 3:

For me, it was enough to ensure that the google-services plugin is initialized in my app.gradle:

apply plugin: 'com.google.gms.google-services'

Then I did not even have to call FirebaseApp.initializeApp(Context) at all. Maybe it helps someone.

Solution 4:

I don't know why this worked for me but removing

tools:node="replace"

from my AndroidManifest.xml improved the crash from right away to from some other thing. Hope I helped someone.

Post a Comment for "Make Sure To Call Firebaseapp.initializeapp(context) First"