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

RNFirebase core module was not found natively on Android, ensure you have correctly added the RNFirebase and Firebase gradle dependencies to your `android/app/build.gradle` file.

Open Mifayo opened this issue 8 years ago • 53 comments

file android/app/build.gradle

dependencies { compile(project(':react-native-firebase')) { transitive = false } compile "com.google.android.gms:play-services-base:11.6.0" compile "com.google.firebase:firebase-core:11.6.0" compile "com.google.firebase:firebase-analytics:11.6.0" compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // From node_modules }

file android/build.gradle

buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.google.gms:google-services:3.1.1' } } allprojects { repositories { mavenLocal() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } // ------------------------------------------------- // Add this below the existing maven property above // ------------------------------------------------- maven { url 'https://maven.google.com' } } }

"react": "16.0.0-alpha.12", "react-native": "0.48.3", "react-native-firebase": "^3.1.1"

Mifayo avatar Dec 11 '17 15:12 Mifayo

RNFirebase core module was not found natively on Android, ensure you have correctly added the RNFirebase and Firebase gradle dependencies to your `android/app/build.gradle` file.

Did you figure out a way to get past this?

I am in the same boat. It's working fine for iOS but I get this message on android as soon as I add import RNFirebase from 'react-native-firebase' in the component I am going to init things in. I have been over the install docs for android 5x and my gradle files are same as above.

"react": "16.0.0-alpha.12" "react-native-firebase": "^3.1.1" "react-native": "^0.50.3"

code-matt avatar Dec 15 '17 18:12 code-matt

Actually, I just got it building 5 mins after posting this. I followed the directions to the letter and

import io.invertase.firebase.RNFirebasePackage; and new RNFirebasePackage()

were never added to my MainApplication.java. What step was supposed to add these for me since its not mentioned in the Android install documentation ?

code-matt avatar Dec 15 '17 18:12 code-matt

@code-matt this should be performed by react-native link?

chrisbianca avatar Dec 15 '17 18:12 chrisbianca

I had done that step, not sure why its not working? I even did it on a clean project while I was trying to narrow down what was wrong and still had these errors.

Now that it is building, I see now when you are missing a firebase module, the error message is very descriptive and tells you there are imports and new lines missing from MainApplication.java.

Perhaps the error message mentioned in this issue could be as descriptive ?

code-matt avatar Dec 15 '17 18:12 code-matt

@code-matt i did that too and it works for me i see after i linked a lot of library some libraries doesn't linked automaticly with react-nataive link :/ i just don't know why thanks guys

Mifayo avatar Dec 16 '17 15:12 Mifayo

Hi there! I would like to know if someone have solved this problem? I have the same sympthoms, but in production build only! In dev the things work totally fine. How is it possible if gradle config is the same for release and for debug? Could be the problem in ExpoKit, which I use?

RN 0.51, Expo SDK 24.0.0, RNFirebase 3.2.1, Firebase Android SDK 11.8.0

priezz avatar Jan 11 '18 15:01 priezz

@priezz For me, this problem was solved by simply removing my app from the device/emulator and then reinstalling using react-native run-android.

anthonydito avatar Jan 16 '18 03:01 anthonydito

I've just gone through and:

  1. Setup a clean project using react-native init
  2. Followed the installation instructions for react-native firebase including react-native link
  3. Added console.log('Firebase: ', firebase.app());

And got the following:

Firebase: FirebaseApp {_name: "[DEFAULT]", _namespaces: {…}, _options: {…}, _initialized: true, _nativeInitialized: true, …}

Everything works correctly, closing.

chrisbianca avatar Jan 26 '18 11:01 chrisbianca

I am still having the same problem when trying with expo i.e. Create-React-Native-App method. I tried everything mentioned in these comments but getting the same error...

    compile project(':react-native-shared-preferences')
    compile project(':react-native-fcm')
    compile(project(':react-native-firebase:3.2.7')) {
        transitive = true
    }
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"
    compile "com.google.firebase:react-native-firebase-core:11.6.0"
    compile "com.google.firebase:firebase-core:11.6.0"
    compile "com.google.android.gms:play-services-base:11.6.0"
    compile "com.google.firebase:firebase-messaging:11.6.0"  // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

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

vaibhavk98 avatar Feb 25 '18 09:02 vaibhavk98

had this error too, followed @code-matt but also had to add to the MainApp.js import io.invertase.firebase.database.RNFirebaseDatabasePackage; and new RNFirebaseDatabasePackage() and in the android/app/gradle.properties i had to add com.google.firebase:firebase-database:11.+ where 11.+ could be another version like 12.0.0

Sleepful avatar Apr 11 '18 05:04 Sleepful

@chrisbianca

When you originally create your react native project their generator asks for your app name. Then it scaffolds out a directory android/app/src/main/java/com/<app_name>/. It also gives your app a bundle id (in android this is your package name) of com.<app_name>.

This default was not what I wanted my bundle id to be so I changed it. I didn't however go through the process of updating the android directory structure to match the new bundle id. So when the react-native link react-native-firebase command was run it looked at my bundle id and then used that to try and find my MainApplication.java file, which it couldn't because that's not where it is.

I have used react-native link to bring in other third party libraries without this issue so I'm guessing it's the way you have implemented your link command. May be worth looking at how other libraries do it to account for the bundle id / package name being changed. If nothing else just update the docs to let people know they'll have to manually update their MainApplication.java if they've changed their package name and not updated their dir structure.

runia1 avatar Apr 27 '18 20:04 runia1

@runia1 we don't do anything special with our link statement - we just use the underlying rnpm functionality that's built into react-native.

chrisbianca avatar Apr 29 '18 08:04 chrisbianca

Hmm, that's very odd behavior then. Seeing as how other people are also experiencing it, maybe just add a little comment to the install docs and hope that helps others.

runia1 avatar May 01 '18 03:05 runia1

I have followed the steps by @code-matt and it's still not working, I have also made sure that I have thoroughly followed the installation instructions at https://rnfirebase.io for android but I still see the red screen whenever I add the line: import firebase from "react-native-firebase". Any help would be much appreciated. thanks.

oliverboamah avatar Jul 31 '18 15:07 oliverboamah

any solution ? yet ?

abdul-elah-js avatar Sep 06 '18 19:09 abdul-elah-js

I am having the same issue

harrymash2006 avatar Sep 11 '18 23:09 harrymash2006

Same issue for me.

nndurj avatar Sep 18 '18 17:09 nndurj

i found a workaround in my particular situation .. running react-native run-android without specifying the device id, and shutting down the emulator worked for me, hope it helps someone.

abdul-elah-js avatar Sep 29 '18 00:09 abdul-elah-js

add this in android/app/build.gradle dependencies { implementation project(':react-native-firebase') }

add this in android/app/settings.gradle

include ':react-native-firebase' project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')

MuhammadUmairMoosani avatar Jan 14 '19 10:01 MuhammadUmairMoosani

Anyone has fix this problem ?

linhnh123 avatar Jan 17 '19 04:01 linhnh123