react-native-fcm icon indicating copy to clipboard operation
react-native-fcm copied to clipboard

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

Open AlaaAttyaMohamed opened this issue 7 years ago • 18 comments

RN version: "react-native": "0.35.0" "react": "15.3.2"

When i build and android app and try to run the apk on mobile i get this issue

05-07 07:11:54.733 7587-7624/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: com.mstore, PID: 7587 java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.mstore. Make sure to call FirebaseApp.initializeApp(Context) first. at com.google.firebase.FirebaseApp.getInstance(Unknown Source) at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source) at com.evollu.react.fcm.FIRMessagingModule.getFCMToken(FIRMessagingModule.java:73) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:318) at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) at android.os.Looper.loop(Looper.java:148) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) at java.lang.Thread.run(Thread.java:818)

AlaaAttyaMohamed avatar May 07 '17 05:05 AlaaAttyaMohamed

You're probably missing

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

That fixed it for me.

djohnkirby avatar Jun 05 '17 16:06 djohnkirby

@AlaaAttyaMohamed is the issue fixed?

evollu avatar Jun 11 '17 13:06 evollu

@evollu i got same error, "Error: Default FirebaseApp is not initialized in this process com.luthfi. Make sure to call FirebaseApp.initializeApp(Context) first."

my react native apps build was success, no error. but when I try example code in example folder, I got above error.

luthfidc03 avatar Sep 06 '17 08:09 luthfidc03

try update your google play library again? I don't have the issue

evollu avatar Sep 06 '17 13:09 evollu

I am getting the same error

Error: Default FirebaseApp is not initialized in this process com.luthfi. Make sure to call FirebaseApp.initializeApp(Context) first

shruti8597 avatar Oct 29 '17 12:10 shruti8597

@shruti8597 it is most likely your config issue. google this error and check potential fixes

evollu avatar Oct 29 '17 17:10 evollu

Need to do 2 things:

  1. Add this to your project level gradle - classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
  2. Add this to your app level gradle - apply plugin: 'com.google.gms.google-services' Works for me

ap-pankaj avatar Jul 09 '18 14:07 ap-pankaj

I already have these 2 things:

Add this to your project level gradle - classpath 'com.google.gms:google-services:4.0.1' // google-services plugin Add this to your app level gradle - apply plugin: 'com.google.gms.google-services' Works for me

but this is not working for me..... Please suggest me how to solve this issue

snehazanzane avatar Dec 27 '18 10:12 snehazanzane

@snehazanzane I agree with you. None of the solutions seem to be working.

CognitiveClouds-Prasad avatar Jan 16 '19 07:01 CognitiveClouds-Prasad

I am using react-native-push-notification but had the same error. Concerning the build config the RN firebase docs have helped me a lot! Also make sure you use Android Studio since it really helps you with keeping all the dependencies in sync.

jneuendorf avatar Feb 04 '19 15:02 jneuendorf

dependencies { classpath 'com.android.tools.build:gradle:3.3.1' classpath 'com.google.gms:google-services:4.0.1'

} //This IS Work for me

mohitjadav86 avatar Mar 06 '19 04:03 mohitjadav86

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cratisspace.wewriteone.ghmc_new/com.cratisspace.wewriteone.ghmc_new.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.cratisspace.wewriteone.ghmc_new. Make sure to call FirebaseApp.initializeApp(Context) first.

BAvinash avatar Mar 23 '19 16:03 BAvinash

am also getting same

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cratisspace.wewriteone.ghmc_new/com.cratisspace.wewriteone.ghmc_new.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.cratisspace.wewriteone.ghmc_new. Make sure to call FirebaseApp.initializeApp(Context) first.

FirebaseApp.initializeApp(Context)

BAvinash avatar Mar 23 '19 16:03 BAvinash

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cratisspace.wewriteone.ghmc_new/com.cratisspace.wewriteone.ghmc_new.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.cratisspace.wewriteone.ghmc_new. Make sure to call FirebaseApp.initializeApp(Context) first.

try out this// dependencies { classpath 'com.android.tools.build:gradle:3.3.1' classpath 'com.google.gms:google-services:4.0.1'

}

mohitjadav86 avatar Mar 24 '19 16:03 mohitjadav86

Reason and solution: This is the common error you will get most of the time. Reason: when you integrate your project with the Firebase it adds the dependencies implementation 'com.google.firebase:firebase-auth:16.1.0' implementation 'com.google.android.gms:play-services-auth:16.0.1' and classpath classpath 'com.google.gms:google-services:4.1.0'

you just need to update them This is how you can update https://youtu.be/5d1g9aqczIE

am9072 avatar Apr 05 '19 10:04 am9072

Need to do 2 things:

  1. Add this to your project level gradle - classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
  2. Add this to your app level gradle - apply plugin: 'com.google.gms.google-services' Works for me
  1. add google-services.json file to app folder downloaded from firebase dashboard

dnolbon avatar Jun 10 '19 14:06 dnolbon

Need to do 2 things:

  1. Add this to your project level gradle - classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
  2. Add this to your app level gradle - apply plugin: 'com.google.gms.google-services' Works for me

I will add, just in case it helps anybody, that I had these in place too and was still getting the error. However my version was 4.1.0 instead of 4.0.1, and changing it to 4.0.1 actually solved the issue in my case.

404sand808s avatar Jul 30 '19 21:07 404sand808s

After Adding this apply plugin: 'com.google.gms.google-services' App crashes on android

AnilKumarSamal avatar Aug 01 '19 12:08 AnilKumarSamal