Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp() on Android despite correct setup #7462

Answered by mikehardy
DragomirAndrei19 asked this question in Q&A
Discussion options

React Native 0.71.3 + Typescript. Project uses ProGuard too, apparently.

I'm trying to integrade push notifications through cloud messaging. I've only tested it on Android.

I did all the steps required. What am I missing?

  1. npm install --save @react-native-firebase/app
  2. placed my google-services.json file in /android/app/ folder
  3. Added classpath 'com.google.gms:google-services:4.4.0' at /android/build.gradle
  4. Added apply plugin: 'com.google.gms.google-services' at /android/app/build.gradle
  5. npm install @react-native-firebase/messaging
  6. npx react-native run-android to rebuild the project
    7)import messaging from '@react-native-firebase/messaging';in my App.tsx
  7. For testing, I'm adding this function from the documentation
async function requestUserPermission() {
 const authStatus = await messaging().requestPermission();
 const enabled =
 authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
 authStatus === messaging.AuthorizationStatus.PROVISIONAL;
 if (enabled) {
 console.log('Authorization status:', authStatus);
 }
}
  1. I call the function inside an useEffect() in App.tsx

Yet, despite all these steps, I keep getting

 Possible Unhandled Promise Rejection (id: 0):
Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()

What am I missing? This is driving me insane.

You must be logged in to vote

Reproduced. On rn71 stock templates if you use google-services 4.4.0 it fails on android in exactly the way you describe

If you use rn71 you must use google-services 4.3.15 - it works fine
If you use rn72 you may update to google-services 4.4.0 - it works fine

I'll post a note in the install documentation

Thanks for noticing this!

Replies: 18 comments 25 replies

Comment options

Hey there 👋 - there must be some steps after step 9? Like "then I run the pod install / build for whatever platform etc" ? I'm not sure which platform the problem is on so I can't say what those commands should be but if you specify what you do I may be able to help more.

Alternatively you can have a quick read through the comments on my "build a firebase app from scratch, start to finish in one script" script where I demonstrate how to do the integration: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

You must be logged in to vote
0 replies
Comment options

Hi. I'm having the same issue, which has also drove me insane, well almost. ;-). My findings so far:

  • In my case, the NATIVE_FIREBASE_APPS array of the RNFBAppModule Native Module seems to be empty on Android. On iOS, this array contains 1 element, which is a reference to the Firebase App on the native side. On Android, this array is filled in the getConstants method of the ReactNativeFirebaseAppModule (contained in the @react-native-firebase/app package).
  • To research the issue further, I have set up 2 basic React Native projects (using the npx react-native init command). One project uses RN version 0.71.13 and the other version 0.72.7. To both projects, I have added the latest @react-native-firebase/app package (18.6.1) and added the google services gradle plugin and the google services json file. On the 0.72.7 version, everything works as expected and on the 0.71.13 version the same error is seen.
  • The Google Services grade plugin should parse the google services json file and create 1 (or 2?) xml files (see android/app/build/generated/res/) that are then used at runtime to initialize the Firebase objects. In the 0.71.13 project, these files are not created while on the 0.72.7 version, these are correctly created.

I suspect that there is some version incompatibility issue between Gradle and the Google Services gradle plugin.

You must be logged in to vote
12 replies
Comment options

@sander48k very interesting finding. rn71 certainly worked when I was build-testing while it was out

At the time the google-services plugin version was 4.3.15 - have you tried that one in combination with react-native 0.71.x ?

I've branched my reproducible build-test repo at the commit where rn71 was last used (implying it uses google services plugin 4.3.15, not current / 4.4.0),

I'm running a build test now https://github.com/mikehardy/rnfbdemo/blob/rn71/make-demo.sh but may run out of time today before I can report more results.

It does seem that upgrading to react-native 0.72 is a obvious pathway to success here though :-)

Comment options

Reproduced. On rn71 stock templates if you use google-services 4.4.0 it fails on android in exactly the way you describe

If you use rn71 you must use google-services 4.3.15 - it works fine
If you use rn72 you may update to google-services 4.4.0 - it works fine

I'll post a note in the install documentation

Thanks for noticing this!

Answer selected by mikehardy
Comment options

Thanks Mike! Good to know that version 4.3.15 works with my rn71 project!

Comment options

Hi @sander48k @mikehardy

I am using this configuration and tried both the google-service version but Its not working for me.

"react-native": "0.72.7",
 classpath 'com.google.gms:google-services:4.3.15'
 distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
Comment options

I am also facing the same issue

Comment options

I am also facing the same issue. @mikehardy

Comment options

in my case, another problem was that i had missed the step 4 which @DragomirAndrei19 mentioned:
"Added apply plugin: 'com.google.gms.google-services' at /android/app/build.gradle"

(it's just one line in the documentation and i had missed it! took me a day to figure that out😑)

anyway I ended up using RN 0.72.6 and com.google.gms:google-services:4.4.0.

You must be logged in to vote
2 replies
Comment options

thank you its worked. its my saved day :)

Comment options

Should be 4.4.2 now though :-), cheers
https://firebase.google.com/support/release-notes/android (all versions are listed there, our docs should have the versions up to date as well)

Comment options

Hi @mikehardy
No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
RN 0.73.6
gradle version 8
classpath 'com.google.gms:google-services:4.4.1'

You must be logged in to vote
1 reply
Comment options

@zocial-rajesh --> does not reproduce: https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh

You might examine the output of that from-scratch successful-build reproducer and see if you can find the difference in your gradle files, that should get you going

Comment options

I have same issue in RN latest version:

(NOBRIDGE) ERROR Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()

"react-native": "0.74.0"
classpath("com.google.gms:google-services:4.4.1")

You must be logged in to vote
0 replies
Comment options

Same issue on react native 0.74

(NOBRIDGE) ERROR Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()

"react-native": "0.74.0"
classpath("com.google.gms:google-services:4.4.1")

You must be logged in to vote
0 replies
Comment options

You need to configure crashlytics(or any other firebase services which u want) separately after configuring firebase https://rnfirebase.io/crashlytics/usage
There are some additional steps here.

You must be logged in to vote
0 replies
Comment options

#7788 (comment)

the fix for react-native 0.74

You must be logged in to vote
0 replies
Comment options

Does anybody know why I get this error?

Plugin with id 'com.google.gms.google-service' not found

You must be logged in to vote
1 reply
Comment options

Maybe you forgot to add the plugin in your app/build.gradle?

Comment options

I'm using Expo and using typescript. In my case plugins were not working so I had to go with React Native CLI - Android Setup instead of Expo.

"react-native": "0.74.3"
"expo": "^51.0.21"
"@react-native-firebase/app": "^20.3.0"
"@react-native-firebase/messaging": "^20.3.0"

You must be logged in to vote
2 replies
Comment options

I'm using Expo and using typescript. In my case plugins were not working so I had to go with React Native CLI - Android Setup instead of Expo.

React Native CLI - Android Setup documentation for expo solved my issue

adding in app.json :

"plugins": [
"@react-native-firebase/app",
"@react-native-firebase/messaging"
]

solved the "call firebase.InitializeApp()" issue,

still didn't get the notification so i added the permission of expo-notifications and it's working now...

Comment options

Adding the plugins to app.json worked (I'm running RN 0.74.5) but I also had to run npx expo prebuild --clean before it would add the com.google.gms:google-services:4.4.1 line to my build.gradle.

Comment options

Double-check if apply plugin: 'com.google.gms.google-services' is added inside build.gradle located inside android/app folder

Ref: #7788 (comment)

You must be logged in to vote
0 replies
Comment options

I forgot to add my iOS credentials to AppDelegate.m, and that I have it works!

Check out items 2 and 3 here: https://rnfirebase.io/

You must be logged in to vote
0 replies
Comment options

I resolved the issue by updating the package.json dependencies for Firebase:

"dependencies": {
 "@react-native-firebase/app": "^21.3.0",
 "@react-native-firebase/messaging": "^21.3.0"
}

I found the latest compatible versions on the npm website.

You must be logged in to vote
3 replies
Comment options

I resolved the issue by updating the package.json dependencies for Firebase:

"dependencies": {
 "@react-native-firebase/app": "^21.3.0",
 "@react-native-firebase/messaging": "^21.3.0"
}

I found the latest compatible versions on the npm website.

This solution worked for me! I had to update all my firebase dependencies and I'm using the following versions:

  • RN: 0.76.1;
  • @react-native-firebase/app: 21.5.0;
Comment options

"@react-native-firebase/app": "^21.3.0",
"@react-native-firebase/messaging": "^21.3.0"

it worked for me

Comment options

This works for me
"react-native": "0.76.6",
"@react-native-firebase/app": "21.3.0",

Comment options

Tried to fix it with the following setup:

Dependencies Tried:
"react-native": "0.75.4",
"expo": "^51.0.31",
"@react-native-firebase/app": "^21.3.0" AND "^21.6.1"
"@react-native-firebase/messaging": "^21.3.0" AND "^21.6.1",

Different try:
"expo": "^52.0.11" with
"react-native": "0.76.3"

react-native failed to have compatibility for aws/amplify UI, so didn't get to check if it was working with Firebase.
You must be logged in to vote
1 reply
Comment options

@mikehardy i am facing same issue on android and ios. i have checked the confirguration multiple times and its correct also google-service.json and GoogleService-Info.plist is placed in correct directory. Here is my version of firebase and react native
"@react-native-firebase/app": "21.10.1",
"@react-native-firebase/messaging": "21.10.1",
"react": "18.3.1",
"react-native": "0.76.9",

You must be logged in to vote
2 replies
Comment options

So, you are on an old react-native, you likely need google-services gradle plugin 4.3.15, as indicated above @Muhammadmahadsaeed

What version of that plugin are you using?

Comment options

@mikehardy i am using this classpath 'com.google.gms:google-services:4.4.2' and also tried with 4.3.15 but still facing same issue on android and ios

Comment options

I got that error after upgrading React Native from 0.72 to 0.77 version

New Arch: disabled
Hermes: disabled
Firebase: 12.9.3

My fix in android/build.gradle

- classpath 'com.google.gms:google-services:4.3.10'
+ classpath 'com.google.gms:google-services:4.4.3'

I hope it will help someone

#2701 (comment)

You must be logged in to vote
1 reply
Comment options

The solution for me was to revert to the old value for newArchEnabled=false, upgrading react-native sets this value to true, which causes problems.

Comment options

Same issue, I am using "@react-native-firebase/app": "^23.3.0"

You must be logged in to vote
0 replies
Comment options

getting the same error when trying to run on android. using react-native : 0.81.4. using version 23.3.1 for my firebase packages. using version 4.4.3 for google services.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /