React-native-firebase: RNFirebase core module was not found natively on Android after Expo eject & detach

Created on 12 Sep 2018  路  21Comments  路  Source: invertase/react-native-firebase

Issue

I created an app using create-react-native-app
I detached & ejected Expo so i can now use native module for both IOS & Android.
I installed react-native-firebase perfectly on IOS but i happen to have this issue for Android.

img_1743

I followed every instruction more than once but can't make it work.

Here are my gradles :

/android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
  repositories {
  mavenLocal()
    google()
    jcenter()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath 'com.google.gms:google-services:4.0.1'
    classpath 'de.undercouch:gradle-download-task:2.0.0'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
  }
}

allprojects {
  repositories {
    maven {
      url "$rootDir/maven"
    }
    maven {
      // We use a modified build of com.android.support.test:runner:1.0.1. Explanation in maven-test/README
      url "$rootDir/maven-test"
    }
    jcenter()
    maven {
      // Local Maven repo containing AARs with JSC built for Android
      url "$rootDir/../js/node_modules/jsc-android/android"
    }
    flatDir {
      dirs 'libs'
      // dirs project(':expoview').file('libs')
    }
    maven { url "https://jitpack.io" }
    maven {
      url 'https://maven.google.com'
    }

    // Want this last so that we never end up with a stale cache
    mavenLocal()
  }
}

task clean(type: Delete) {
  delete rootProject.buildDir
}

/android/app/build.gradle

buildscript {
  repositories {
    maven { url 'https://maven.fabric.io/public' }
  }

  dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
  }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.neenbedankt.android-apt'

repositories {
  maven { url 'https://maven.fabric.io/public' }
}

android {
  compileSdkVersion 26
  buildToolsVersion '26.0.1'

  defaultConfig {
    applicationId 'com.ronin.duo'
    targetSdkVersion 25
    versionCode 1
    versionName '1.0.0'
    ndk {
      abiFilters 'armeabi-v7a', 'x86'
    }
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    // Deprecated. Used by net.openid:appauth
    manifestPlaceholders = [
      'appAuthRedirectScheme': 'host.exp.exponent'
    ]
  }
  dexOptions {
    javaMaxHeapSize System.getenv("DISABLE_DEX_MAX_HEAP") ? null : "8g"
  }
  productFlavors {
    // Define separate dev and prod product flavors.
    dev {
      // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
      // to pre-dex each module and produce an APK that can be tested on
      // Android Lollipop without time consuming dex merging processes.
      minSdkVersion 21
    }
    devRemoteKernel {
      minSdkVersion 21
    }
    dev19 {
      // For debugging / development on older SDK versions. Increases build
      // time so use 'dev' if not running on older SDKs.
      minSdkVersion 19
    }
    prod {
      // The actual minSdkVersion for the application.
      minSdkVersion 19
    }
  }
  buildTypes {
    debug {
      debuggable true
    }
    release {
      minifyEnabled true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      zipAlignEnabled true
    }
  }
  signingConfigs {
    debug {
      storeFile file('../debug.keystore')
    }
  }
  lintOptions {
    abortOnError false
  }
  packagingOptions {
    pickFirst "**"
  }
}

// Don't use modern jsc-android since it still has some critical bugs that
// crash applications when the string for the JS bundle is loaded and when
// locale-specific date functions are called.
// configurations.all {
//   resolutionStrategy {
//     force 'org.webkit:android-jsc:r216113'
//   }
// }


apply from: 'expo.gradle'


dependencies {
    implementation project(':react-native-firebase')
    implementation project(':react-native-fbsdk')
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:multidex:1.0.1'

  // Our dependencies
  implementation 'com.android.support:appcompat-v7:26.0.1'

  // Our dependencies from ExpoView
  // DON'T ADD ANYTHING HERE THAT ISN'T IN EXPOVIEW. ONLY COPY THINGS FROM EXPOVIEW TO HERE.
  implementation 'com.android.support:appcompat-v7:26.0.1'
  implementation 'com.facebook.android:facebook-android-sdk:4.7.0'
  implementation('com.facebook.android:audience-network-sdk:4.22.1') {
    exclude module: 'play-services-ads'
  }
  provided 'org.glassfish:javax.annotation:3.1.1'
  implementation 'com.jakewharton:butterknife:7.0.1'
  implementation 'de.greenrobot:eventbus:2.4.0'
  implementation 'com.amplitude:android-sdk:2.9.2'
  implementation 'com.squareup.picasso:picasso:2.5.2'
  implementation "com.google.firebase:firebase-core:16.0.1"
  implementation "com.google.firebase:firebase-database:16.0.1"
  implementation "com.google.firebase:firebase-auth:16.0.2"
  implementation "com.google.android.gms:play-services-base:16.0.1"
  implementation 'com.google.android.gms:play-services-gcm:16.0.1'
  implementation 'com.google.android.gms:play-services-analytics:16.0.1'
  implementation 'com.google.android.gms:play-services-maps:16.0.1'
  implementation 'com.google.android.gms:play-services-auth:16.0.1'
  implementation 'com.google.android.gms:play-services-location:16.0.1'
  implementation 'com.google.android.gms:play-services-ads:16.0.1'
  apt 'com.raizlabs.android:DBFlow-Compiler:2.2.1'
  implementation "com.raizlabs.android:DBFlow-Core:2.2.1"
  implementation "com.raizlabs.android:DBFlow:2.2.1"
  implementation "com.madgag.spongycastle:core:1.53.0.0"
  implementation "com.madgag.spongycastle:prov:1.53.0.0"
  debugCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
  // debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
  releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
  implementation 'com.facebook.device.yearclass:yearclass:1.0.1'
  implementation 'commons-io:commons-io:1.3.2'
  implementation 'me.leolin:ShortcutBadger:1.1.4@aar'
  implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
  implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
  implementation 'com.yqritc:android-scalablevideoview:1.0.1'
  implementation 'commons-codec:commons-codec:1.10'
  implementation 'com.segment.analytics.android:analytics:4.3.0'
  implementation 'com.google.zxing:core:3.2.1'
  implementation 'net.openid:appauth:0.4.1'
  implementation 'com.airbnb.android:lottie:2.2.0'
  implementation 'io.branch.sdk.android:library:2.6.1'
  implementation('io.nlopez.smartlocation:library:3.2.11') {
    transitive = false
  }
  implementation 'com.android.support:exifinterface:26.0.1'
  implementation 'com.squareup.okhttp3:okhttp:3.4.1'
  implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
  implementation 'com.squareup.okhttp3:okhttp-ws:3.4.1'
  implementation 'com.squareup.okio:okio:1.9.0'

  // Testing
  androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
  // We use a modified build of com.android.support.test:runner:1.0.1. Explanation in maven-test/README
  androidTestCompile 'com.android.support.test:runner:1.0.1'
  androidTestCompile 'com.android.support:support-annotations:26.0.1'
  androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
  androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
  androidTestCompile 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'



  implementation('host.exp.exponent:expoview:27.0.0@aar') {
    transitive = true
  }

  implementation project(path: ':expoview')
}

// This has to be down here for some reason
apply plugin: 'com.google.gms.google-services'

MainApplication.java :

package host.exp.exponent;


import com.facebook.react.ReactPackage;

import java.util.Arrays;
import java.util.List;

import expolib_v1.okhttp3.OkHttpClient;

// Needed for `react-native link`
// import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import io.invertase.firebase.database.RNFirebaseDatabasePackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;

public class MainApplication extends ExpoApplication {

  @Override
  public boolean isDebug() {
    return BuildConfig.DEBUG;
  }

    Log.d(TAG, "INSIDE 2222");

  // Needed for `react-native link`
  public List<ReactPackage> getPackages() {
    Log.d(TAG, "INSIDE 1111");
    return Arrays.<ReactPackage>asList(
        // Add your own packages here!
        // TODO: add native modules!
        // Needed for `react-native link`
            new MainReactPackage(),
            new RNFirebasePackage(),
            new RNFirebaseDatabasePackage(),
            new RNFirebaseAuthPackage(),
            new FBSDKPackage(),
    );
  }

  @Override
  public String gcmSenderId() {
    return getString(R.string.gcm_defaultSenderId);
  }

  @Override
  public boolean shouldUseInternetKernel() {
    return BuildVariantConstants.USE_INTERNET_KERNEL;
  }

  public static OkHttpClient.Builder okHttpClientBuilder(OkHttpClient.Builder builder) {
    // Customize/override OkHttp client here
    return builder;
  }
}

The only difference is that in /android/app/src/main/java there is no folder with the name of my project but this folder structure created by Expo

capture d ecran 2018-09-12 a 22 13 20

Environment

  1. Application Target Platform:

Android

  1. Development Operating System:

MacOS HighSierra

  1. React Native version:

https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz

  1. React Native Firebase Version:

^4.3.8

  1. Firebase Module:

Core

  1. Are you using typescript?

no


Loving react-native-firebase? Please consider supporting them with any of the below:

Build Error

All 21 comments

i have the same issue i am trying since 4 hours to solve it, but it dose not work.

@moddatherrashed Did you detached & ejected Expo aswell ? And is it working fine on IOS ?

@QQizi no i had an Expo project, and to show the android and iOS folders i did run (exp detach), it is kind of the same but i did it the opposite way.
and i did not try it yet on iOS.
i am struggling man !

@QQizi try react-native link ! what it gives you ?

@moddatherrashed I did use react-native link with no success

@QQizi i need to give it by the end of this week ! shit !

@Salakar Already did. I updated my first post with MainApplication.java

@Salakar where should we find firebase.js script ?

node_modules/react-native-firebase/dist/modules/core/firebase.js

@Salakar

capture d ecran 2018-09-13 a 00 08 18

I'm able to debug in L131 & NativeModules looks fine

@Salakar here is the debug result --> 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.

and the nativeModules seems to be fine

Can you expand the output of NativeModules on the console there please, not showing the full log - you can do console.log(Object.keys(NativeModules));

@Salakar

(94)聽["ImageLoader", "DialogManagerAndroid", "ExponentTest", "FileReaderModule", "PermissionsAndroid", "ExponentContacts", "ExponentFontLoader", "ExponentWebBrowser", "ExponentCrypto", "Networking", "RNAdMobRewarded", "ExponentFileSystem", "ToastAndroid", "StripeModule", "JSCSamplingProfiler", "ExponentMagnetometerUncalibrated", "StatusBarManager", "WebSocketModule", "ExponentPedometer", "ExponentScreenOrientation", "ExponentSQLite", "ExponentAmplitude", "ExponentDocumentPicker", "TimePickerAndroid", "RNGestureHandlerModule", "DatePickerAndroid", "I18nManager", "AppState", "ExponentBrightness", "RNViewShot", "ExponentMailComposer", "IntentAndroid", "CTKInterstitialAdManager", "ExponentFabric", "ExponentFingerprint", "EXURLHandler", "ExponentLocalization", "ExponentSpeech", "RNAdMobInterstitial", "ExponentKeyboard", "ExponentBarCodeScannerModule", "NativeAnimatedModule", "ExponentImageCropper", "ExponentErrorRecovery", "ExponentLocation", "ExponentPermissions", "JSCHeapCapture", "ExponentUpdates", "ImageStoreManager", "ExponentMagnetometer", "Timing", "ExponentCameraModule", "UIManager", "JSDevSupport", "ExpoFaceDetector", "ExponentNotifications", "SourceCode", "ExponentImageManipulator", "PlatformConstants", "ExponentGyroscope", "ExponentMediaLibrary", "ExponentImagePicker", "HeadlessJsTaskSupport", "Vibration", "CTKAdSettingsManager", "ExponentDeviceMotion", "ExponentIntentLauncher", "Clipboard", "ExponentKeepAwake", "DeviceEventManager", "CameraRollManager", "DeviceInfo", "ExponentFacebook", "BlobModule", "RNAWSCognito", "ExponentAccelerometer", "RNBranch", "ExponentGLObjectManager", "ExponentPrint", "ExponentSegment", "ExponentVideoManager", "NetInfo", "CTKNativeAdManager", "ExponentGoogle", "AccessibilityInfo", "ExponentConstants", "ExponentSecureStore", "LocationObserver", "ExponentCalendar", "ShareModule", "AsyncSQLiteDBStorage", "ExceptionsManager", "ExponentAV", "ImageEditingManager"]

I don't think you're adding the native modules to the right place on Android code otherwise they'd be showing in that list of NativeModules.

cc @EvanBacon - could you point us in the right direction of where extra native modules can be added in ExpoKit.

@Salakar Don't you think it can come from this point i explained in my first message :
The only difference is that in /android/app/src/main/java there is no folder with the name of my project but this folder structure created by Expo

Maybe the path where the app is trying to get some module doesn't works ?

Well, for the third time in a row, i drop Expo after a few days of dev. Maybe one day this framework will be stable enough to actually be used.

@QQizi I did the same, no chance to make it work except that !

Pretty close to landing the beta version of expo-firebase.

Will close as this is not an issue with this library, please consult the expo documentation on how and where to integrate custom native modules as this isn't the right place for it.

Thanks

Was this page helpful?
0 / 5 - 0 ratings