React-native-fcm: Default FirebaseApp is not initialized in this process. Make sure to call FirebaseApp.initializeApp(Context) first.

Created on 6 Sep 2017  路  6Comments  路  Source: evollu/react-native-fcm

my react native apps build was success, no error. but when I try example code in example folder, I got above error Default FirebaseApp is not initialized in this process. Make sure to call FirebaseApp.initializeApp(Context) first.

screenshot_2017-09-06-19-11-18 1

if I put apply plugin: 'com.google.gms.google-services' line in the end of android/app/build.gradle, I got an error when built it, but when I commented it, its going well.
@evollu @benoist @ibratoev @radev @zaro @jerolimov

what should I do? its been 3 days im working on it

here is my package.json

{
  "dependencies": {
    "firebase": "^4.3.0",
    "moment": "^2.18.1",
    "react": "16.0.0-alpha.12",
    "react-native": "0.47.2",
    "react-native-camera": "git+https://github.com/lwansbrough/react-native-camera.git",
    "react-native-elements": "^0.16.0",
    "react-native-fcm": "^9.1.0",
    "react-native-fetch-blob": "^0.10.8",
    "react-native-google-signin": "^0.12.0",
    "react-native-linear-gradient": "^2.2.0",
    "react-native-progress": "^3.4.0",
    "react-native-tabs": "^1.0.9",
    "react-native-vector-icons": "^4.3.0",
    "react-navigation": "^1.0.0-beta.11",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "babel-jest": "20.0.3",
    "babel-preset-react-native": "3.0.1",
    "jest": "20.0.4",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "jest": {
    "preset": "react-native"
  }

Most helpful comment

apply plugin: 'com.google.gms.google-services' is required. try apply it on the top?

All 6 comments

apply plugin: 'com.google.gms.google-services' is required. try apply it on the top?

thanks man, its work, maybe after I download Android SDK Build-Tools 23.0.3, I dont know, its magically work, cheers

@luthfidc03 i can't build fcm with android. could you give me your app/build.gradle file.

I had to add the following lines to MainApplication.java to get it working:

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    try {
        FirebaseApp.initializeApp(this);
    }
    catch (Exception e) {
    }
  }

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Keksike picture Keksike  路  5Comments

Przemocny picture Przemocny  路  3Comments

prashant-gaurav picture prashant-gaurav  路  5Comments

mts88 picture mts88  路  5Comments

jitenderchand1 picture jitenderchand1  路  4Comments