React-native-firebase: 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.

Created on 11 Dec 2017  路  51Comments  路  Source: invertase/react-native-firebase

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"

Most helpful comment

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 ?

All 51 comments

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"

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 this should be performed by react-native link?

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 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

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 For me, this problem was solved by simply removing my app from the device/emulator and then reinstalling using react-native run-android.

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.

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...
```dependencies {
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'```

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

@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 we don't do anything special with our link statement - we just use the underlying rnpm functionality that's built into react-native.

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.

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.

any solution ? yet ?

I am having the same issue

Same issue for me.

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.

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')

Anyone has fix this problem ?

Yes I'm I was commit above how to solve this issue

@MuhammadUmairMoosani Still not working. I'm using react-native 0.55.4, react-native-firebase 4.3.8

has any one found a solution for this,

Yes, the best way is to look at the firebase starter and do exactly what it does. Probably a failure to link (which is settings.gradle, build.gradle, and MainApplication.java work)

anyone has a solution now
i am facing the same problem

For an example of how to do react-native 0.60 - https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

For react-native 0.59 - https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-rn59.sh

Study how they do what they do, and do that in your project

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 ?

I have those in place but still. I get the same error!

@4RGUS this has been closed nearly two years now - you should open a new issue and follow the issue template to receive help

@4RGUS this has been closed nearly two years now - you should open a new issue and follow the issue template to receive help

Okay, Thank you

I have same problem on Android, the version I use is @react-native-firebase/app (version 6+), on iOS it is fine, but has the same error on Android, I tried to add the dependencies, still not working

Happening with RN 0.60.6

fixed changing import firebase from "react-native-firebase" to import * as firebase from "firebase";

Any updates on how to resolve this issue? I migrated from version 5 to 6, and can't seem to figure out the solution.

Integrate it properly? Example integration from scratch, compare with your project to see where your android gradle / java files are missing something: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh

I'm at version 5.6.x and I'm having the same issues as well. I've tried running the script above.

This worked for me from the comment above:

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

version 5 will receive no further support, however there is still a valid demonstration of v5 working in both RN<60 https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-rn59.sh and RN60+ https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

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 documentat

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 ?

where do you add the new RNFirebasePackage?

I'm at version 5.6.x and I'm having the same issues as well. I've tried running the script above.

This worked for me from the comment above:

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

but where do you add the newRNFirePackage()

underneath the import?

@Sfiso-dsw follow what these scripts do EXACTLY and it will work, as the projects that result from the script work

For react-native 59 and react-native-firebase v5 (but please note these will receive no support, they are way too old: you need to upgrade): https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-rn59.sh

For rn60+ and rnfb v5 (but please upgrade to rnfb v6+, v5 will receive no support): https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

For current recommended versions, where you may get support: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh

fixed changing import firebase from "react-native-firebase" to import * as firebase from "firebase";

this worked

Still have same issue for [email protected] and @react-native-firebase/[email protected].
I can see new ReactNativeFirebaseAppPackage() already appear in PackageList (by auto linking).
I also have followed the instruction in this link https://rnfirebase.io/install-android . but, still no luck :(

2020-10-08 00:34:10.853 12706-12871/com.my.user E/ReactNativeJS: 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.

     See http://invertase.link/android for the android setup guide.

@ooca-big why woul dyou be on [email protected] ? it is at 8.4.5 now

@ooca-big why woul dyou be on [email protected] ? it is at 8.4.5 now

@mikehardy I used to be on @latest but it wasn't work. So, I downgraded to @6 which was resolved to 6.7.1.

I support current stable, sorry - if you were maintaining a library can you imagine the inefficiency of troubleshooting versions that have known bugs, and rely on SDK versions with known bugs? It's not feasible.

If you can reproduce this against current stable, post an App.js that shows it, ideally off a reproducible demo like https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

I also have this issue, with 8.4.5

@Brumor if you can reproduce with 10.1.0 (current), from a clean demo (e.g., https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh) open a new issue and we can look.

Hi @mikehardy,
I have tested the same in 10.1.0 too. facing the same issue in 10.1.0.

@praveenp-od What worked for me was to go in Android Studio and do File > Invalidate Caches & Restart.

then I also had to run npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res but I'm not certain that it is related to this.

we have updated the react-native version from V5 to V6 in our existing app using the migration documentation. App crash issue occur for us only on fresh install and after that App starts working properly.

E/ReactNativeJS: 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.

See http://invertase.link/android for the android setup guide.
2020-12-10 17:05:44.032 7230-7632/? E/ReactNativeJS: Module AppRegistry is not a registered callable module (calling runApplication)

--------- beginning of crash
2020-12-10 17:05:44.036 7230-7633/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: com.app, PID: 7230
com.facebook.react.common.JavascriptException: 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.

See http://invertase.link/android for the android setup guide.,
stack: t@573:619
@573:2091
v@2:1474
@572:127
v@2:1474
@571:243
v@2:1474
@516:271
v@2:1474
@480:246
v@2:1474
@341:226
v@2:1474
@6:203
v@2:1474
d@2:876
global code@1992:4

if you can reproduce, from a clean demo (e.g., https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh) open a new issue and we can look.

@praveenp-od What worked for me was to go in Android Studio and do File > Invalidate Caches & Restart.

then I also had to run npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res but I'm not certain that it is related to this.

This one worked for me. I had just migrated from v5 to v6 and was facing this issue in 10.4.0.

Was this page helpful?
0 / 5 - 0 ratings