react-native-notifications: [Android] Fcm support Default FirebaseApp is not initialized in this process

I got the following error after trying a migration:

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

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18

Commits related to this issue

Most upvoted comments

Thanks for all the advices. I can summarize what I did to fix this error using wix/react-native-notifications v1.5.0 (latest version today).

This project migrated from GCM to Firebase and you need to perform these steps:

  • Setup Firebase following the 4 steps of Option 1.
  • You will get a file called google-services.json to add to your android/app folder => android/app/google-services.json.
  • In step 4, you added implementation 'com.google.firebase:firebase-core:16.0.8', replace it with implementation "com.google.firebase:firebase-messaging:17.3.0" instead.

Your setup should looks now like:

package.json

...
  "dependencies": {
...
    "react-native-notifications": "^1.5.0",
...

build.gradle

...
buildscript {
...
    dependencies {
...
        classpath 'com.google.gms:google-services:4.2.0'
...

app/build.gradle

...
dependencies {
    ...
    implementation "com.google.firebase:firebase-messaging:17.3.0"
    ...
}
...
apply plugin: 'com.google.gms.google-services'

That should definitely be documented but no time for a PR now.

@AugustoAleGon, I was initially having this issue but then I was able to fix it when I got my firebase configuration correct. Here is my configuration I used

In my root project-level build.gradle I added classpath 'com.google.gms:google-services:3.2.1'

buildscript {
    dependencies {
        ...
        // Add this line
        classpath 'com.google.gms:google-services:3.2.1'
    }
}

In my app-level app/build.gradle I added in dependencies an implementation for firebase & applied the gms service at the bottom of my file

dependencies {
    ...
    // Add this line
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation project(':reactnativenotifications')
    ...
}

...
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'

Published new version with this fix: react-native-notifications@1.2.2. Can you please confirm this solves the issue?

Using google-services version 4.3.3 fixed the problem for me.

build.gradle (project level)

buildscript {
  dependencies {
     classpath("com.google.gms:google-services:4.3.3")
  }
}

react-native version: 0.62.18 react-native-notifications version: 3.2.2

I was able to resolve by adding the below line to my dependencies, instead of the ‘firebase-core’ reference, as that caused some Gradle versioning issues for me:

implementation "com.google.firebase:firebase-messaging:17.3.0"

This is the same version of firebase-messaging that’s in the project itself.

I was able to send a successful test message with a title/body using the Firebase Message Composer https://console.firebase.google.com/project/_/notification.