Fresh Detached Expo + RNFirebase not running on Android

Hi,

So I’m trying to start an app using the Detached Expokit and React Native Firebase (v3)

I made a fresh project with exp cli,
followed all the instructions at https://invertase.io/react-native-firebase/ to set up ios, and it runs fine
followed all the instructions to set up on android,
went through some dependency hell between the expo dependencies and firebase dependencies

And now there are no more warnings, and no more errors, but when i try to run the app (either emulator or physical), it loads the js bundle to 100%, then crashes. No errors, or messages, just crash.

Ive tried everything i can think of (clean, rebuild, clear cache, reinstall npm, downgrading to RNFirebase 2x)

has anyone run into this issue before, or know how to fix?
Thanks in advance


project info (ask for more if you need

package.json:

  "dependencies": {
    "expo": "^21.0.0",
    "react": "16.0.0-alpha.12",
    "react-native": "https://github.com/expo/react-native/archive/sdk-21.0.2.tar.gz",
    "react-native-firebase": "^3.0.2"
  }

app.json:

{
  "expo": {
    "name": "xxx",
    "description": "An empty new project",
    "slug": "xxx",
    "privacy": "unlisted",
    "sdkVersion": "20.0.0",
    "version": "1.0.0",
    "orientation": "portrait",
    "primaryColor": "#cccccc",
    "icon": "./assets/icons/app-icon.png",
    "loading": {
      "icon": "./assets/icons/loading-icon.png"
    },
    "packagerOpts": {
      "assetExts": [
        "ttf",
        "mp4"
      ]
    },
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "xxx",
      "publishBundlePath": "ios/xxx/Supporting/shell-app.bundle",
      "publishManifestPath": "ios/xxx/Supporting/shell-app-manifest.json"
    },
    "android": {
      "package": "xxx"
    },
    "isDetached": true,
    "detach": {
      "scheme": "exp7d16843de771498786f3beabce0d6439",
      "iosExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/ios-v1.20.5-sdk21.0.0-xxx.tar.gz",
      "androidExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/android-v1.20.0-sdk21.0.0-xxx.tar.gz"
    }
  }
}

project build.gradle:

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

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'com.google.gms:google-services:3.1.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}

allprojects {
  repositories {
    mavenLocal()
    jcenter()
    maven {
      // Point to local maven repository
      url "$rootDir/../.expo-source/android/maven"
    }
    maven {
      url 'https://maven.google.com'
    }
    maven {
      url "https://jitpack.io"
    }
  }
}

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

app build.gradle:

apply plugin: 'com.android.application'

android {
  compileSdkVersion 25
  buildToolsVersion '25.0.2'

  defaultConfig {
    applicationId "xxx"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    ndk {
      abiFilters 'armeabi-v7a', 'x86'
    }
    manifestPlaceholders = [
      'appAuthRedirectScheme': 'xxx'
    ]
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
  dexOptions {
    javaMaxHeapSize "8g"
  }
  packagingOptions {
    pickFirst 'META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties'
    pickFirst 'META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml'
    pickFirst 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
    pickFirst 'META-INF/maven/com.squareup.okhttp/okhttp/pom.properties'
    pickFirst 'META-INF/maven/com.squareup.okhttp/okhttp/pom.xml'
    pickFirst 'META-INF/maven/com.squareup.okio/okio/pom.properties'
    pickFirst 'META-INF/maven/com.squareup.okio/okio/pom.xml'
    pickFirst 'META-INF/LICENSE'
  }
}

task exponentPrebuildStep(type: Exec) {
  workingDir '../../'

  if (System.getProperty('os.name').toLowerCase().contains('windows')) {
    commandLine 'cmd', '/c', '.\\.expo-source\\android\\detach-scripts\\prepare-detached-build.bat'
  } else {
    commandLine './.expo-source/android/detach-scripts/prepare-detached-build.sh'
  }
}
preBuild.dependsOn exponentPrebuildStep

repositories{
  flatDir{
    dirs 'libs'
  }
  mavenLocal()
  maven { url 'https://maven.fabric.io/public' }
}

dependencies {
  compile(project(':react-native-firebase')) {
    // exclude group: 'com.google.android.gms'
    // exclude group: 'com.google.firebase'
    transitive = false
  }

  // RNFirebase required dependencies
  compile "com.google.firebase:firebase-core:11.4.2"

  // RNFirebase optional dependencies
  // compile "com.google.firebase:firebase-ads:11.4.2"
  // compile "com.google.firebase:firebase-auth:11.4.2"
  // compile "com.google.firebase:firebase-config:11.4.2"
  // compile "com.google.firebase:firebase-crash:11.4.2"
  compile "com.google.firebase:firebase-database:11.4.2"
  // compile "com.google.firebase:firebase-firestore:11.4.2"
  // compile "com.google.firebase:firebase-messaging:11.4.2"
  // compile "com.google.firebase:firebase-perf:11.4.2"
  // compile "com.google.firebase:firebase-storage:11.4.2"

  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  compile ('com.android.support:appcompat-v7:25.3.1') {
    force = true
  }
  compile ('com.android.support:recyclerview-v7:25.3.1') {
    force= true
  }
  compile ('com.android.support:animated-vector-drawable:25.3.1') {
    force= true
  }
//  compile 'com.android.support:multidex:1.0.1'

  
  compile('host.exp.exponent:expoview:21.0.0@aar') {
    exclude group: 'com.google.android.gms'
    exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
    exclude group: 'com.facebook.android', module: 'audience-network-sdk'
    exclude group: 'io.nlopez.smartlocation', module: 'library'
    transitive = true;
  }

  compile ("com.google.android.gms:play-services-base:11.4.2") {
    force = true
  }
  compile ("com.google.android.gms:play-services-maps:11.4.2") {
    force = true
  }
  compile ('com.facebook.android:facebook-android-sdk:4.+') {
    exclude module: 'bolts-android'
  }
  compile('com.facebook.android:audience-network-sdk:4.+') {
    exclude module: 'play-services-ads'
  }
  compile('io.nlopez.smartlocation:library:3.2.11') {
    transitive = false
  }
  
}

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

mainApplication.java:

package xxx;

import android.support.multidex.MultiDexApplication;

import com.facebook.react.ReactPackage;

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

// Needed for `react-native link`
// import com.facebook.react.ReactApplication;

// React Native Firebase
import io.invertase.firebase.RNFirebasePackage; // <-- This should be added already
// Optional packages - add as appropriate
// import io.invertase.firebase.admob.RNFirebaseAdMobPackage; //Firebase AdMob
// import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage; // Firebase Analytics
// import io.invertase.firebase.auth.RNFirebaseAuthPackage; // Firebase Auth
// import io.invertase.firebase.config.RNFirebaseRemoteConfigPackage; // Firebase Remote Config
// import io.invertase.firebase.crash.RNFirebaseCrashPackage; // Firebase Crash Reporting
import io.invertase.firebase.database.RNFirebaseDatabasePackage; // Firebase Realtime Database
// import io.invertase.firebase.firestore.RNFirebaseFirestorePackage; // Firebase Firestore
// import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; // Firebase Cloud Messaging
// import io.invertase.firebase.perf.RNFirebasePerformancePackage; // Firebase Performance
// import io.invertase.firebase.storage.RNFirebaseStoragePackage; // Firebase Storage

public class MainApplication extends MultiDexApplication {

  // Needed for `react-native link`
  public List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        // Add your own packages here!
        // TODO: add cool native modules

        // Needed for `react-native link`
        // new MainReactPackage(),
        new RNFirebasePackage(),
        // Add these packages as appropriate
        // new RNFirebaseAdMobPackage(),
        // new RNFirebaseAnalyticsPackage(),
        // new RNFirebaseAuthPackage(),
        // new RNFirebaseRemoteConfigPackage(),
        // new RNFirebaseCrashPackage(),
        new RNFirebaseDatabasePackage()
        // new RNFirebaseFirestorePackage(),
        // new RNFirebaseMessagingPackage(),
        // new RNFirebasePerformancePackage(),
        // new RNFirebaseStoragePackage()
    );
  }
}

after days of fiddling, i finally got it to run!

The trick was, i had to manually compile each google play service modules that had a version mismatch.

  compile "com.google.android.gms:play-services-base:11.4.2"
  compile "com.google.android.gms:play-services-base-license:11.4.2"
  compile "com.google.android.gms:play-services-ads:11.4.2"
  compile "com.google.android.gms:play-services-ads-lite:11.4.2"
  compile "com.google.android.gms:play-services-ads-license:11.4.2"
  compile "com.google.android.gms:play-services-analytics:11.4.2"
  compile "com.google.android.gms:play-services-analytics-impl:11.4.2"
  compile "com.google.android.gms:play-services-auth:11.4.2"
  compile "com.google.android.gms:play-services-auth-base:11.4.2"
  compile "com.google.android.gms:play-services-fitness:11.4.2"
  compile "com.google.android.gms:play-services-gcm:11.4.2"
  compile "com.google.android.gms:play-services-identity:11.4.2"
  compile "com.google.android.gms:play-services-maps:11.4.2"
  compile "com.google.android.gms:play-services-wallet:11.4.2"

I’ve been stuck on this same issue for the past week. In my case I can’t get even the iOS app to build, I have an app freshly detached to ExpoKit, I followed the instructions at https://invertase.io/react-native-firebase/ to install RNFirebase v3. When I build I get the error ‘RCTEventEmitter.h’ file not found. I’ve tried re-arranging the schema build order (adding React before my project) and disabling parallel builds as described here - https://github.com/facebook/react-native/issues/12042#issuecomment-274800537. Can you please point me in the right direction as to what I’m missing to get this to build. You’re the only person that seems to have gotten this right on the whole internet - I first saw your post on stackoverflow -

My Podfile currently looks like so:

platform :ios, '9.0'

target 'myproject' do
  pod 'ExpoKit',
    :git => "http://github.com/expo/expo.git",
    :tag => "ios/1.20.5",
    :subspecs => [
      "Core",
      "CPP"
    ]

  pod 'React',
    :path => "../node_modules/react-native",
    :subspecs => [
      "Core",
      "ART",
      "RCTActionSheet",
      "RCTAnimation",
      "RCTCameraRoll",
      "RCTGeolocation",
      "RCTImage",
      "RCTNetwork",
      "RCTText",
      "RCTVibration",
      "RCTWebSocket",
      "DevSupport",
      "CxxBridge"
    ]
  pod 'Yoga',
    :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'DoubleConversion',
    :podspec => "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec",
    :inhibit_warnings => true
  pod 'Folly',
    :podspec => "../node_modules/react-native/third-party-podspecs/Folly.podspec",
    :inhibit_warnings => true
  pod 'GLog',
    :podspec => "../node_modules/react-native/third-party-podspecs/GLog.podspec",
    :inhibit_warnings => true


  post_install do |installer|
    installer.pods_project.main_group.tab_width = '2';
    installer.pods_project.main_group.indent_width = '2';

    installer.pod_targets.each do |target|

    if target.pod_name == 'ExpoKit'
      target.native_target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'EX_DETACHED=1'
        # needed for GoogleMaps 2.x
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= []
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '${PODS_ROOT}/GoogleMaps/Base/Frameworks'
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '${PODS_ROOT}/GoogleMaps/Maps/Frameworks'
      end
    end


    # Build React Native with RCT_DEV enabled
    next unless target.pod_name == 'React'
    target.native_target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_DEV=1'
    end

    end
  end

  pod 'Firebase/Core'
  pod 'Firebase/Auth'
end
type or paste code here

hmm, i dont think i ran into any problems with expokit + RNFirebase on ios, it was mostly android that gave me problems.

my podfile looks like this though,

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target 'loop2' do
  pod 'ExpoKit',
    :git => "http://github.com/expo/expo.git",
    :tag => "ios/1.20.5",
    :subspecs => [
      "Core",
      "CPP"
    ]

  pod 'React',
    :path => "../node_modules/react-native",
    :subspecs => [
      "Core",
      "ART",
      "RCTActionSheet",
      "RCTAnimation",
      "RCTCameraRoll",
      "RCTGeolocation",
      "RCTImage",
      "RCTNetwork",
      "RCTText",
      "RCTVibration",
      "RCTWebSocket",
      "DevSupport",
      "BatchedBridge"
    ]
  pod 'Yoga',
    :path => "../node_modules/react-native/ReactCommon/yoga"

  pod 'Firebase/Core'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
  # pod 'Firebase/AdMob'
  pod 'Firebase/Auth'
  pod 'Firebase/Crash'
  pod 'Firebase/Database'
  # pod 'Firebase/DynamicLinks'
  # pod 'Firebase/Firestore'
  # pod 'Firebase/Messaging'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Storage'

  post_install do |installer|
    installer.pods_project.main_group.tab_width = '2';
    installer.pods_project.main_group.indent_width = '2';

    installer.pod_targets.each do |target|

    if target.pod_name == 'ExpoKit'
      target.native_target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'EX_DETACHED=1'
        # needed for GoogleMaps 2.x
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= []
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '${PODS_ROOT}/GoogleMaps/Base/Frameworks'
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '${PODS_ROOT}/GoogleMaps/Maps/Frameworks'
      end
    end


    # Build React Native with RCT_DEV enabled
    next unless target.pod_name == 'React'
    target.native_target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_DEV=1'
    end

    end
  end
end

and the trick for android, was to open the project in Android Studio, try to build, and look through the gradle files looking for anything that had squigly lines underneath (indicating an error/warning).

Those warnings usually say something about version mismatching and for each of those files that have different versions, i had to explicitly require them in the file with the most up to date version (like in the comment above.

Although, at the end of the day, the creator of React Native Firebase and another “react native consultant” told me that i was better off not using detached expokit as a lib bc of dependency hell.

So I made a clean project with CRNA, ejected without expokit, and linked up the 5 modules i needed.

friend, you could share an example where you use Cloud firestore with expo, since I am very confused with that subject. Looking for information I found that to store Offline data in react-native you need RNfirebase, but for this you must configure the .gradle something that Expo does not bring by default. I appreciate if you can share an example of how to use this.

sorry, I’m not using Cloud Firestore in my app, nor am I storing offline data :frowning:

What do you mean in “i had to manually compile” ? Did you just changed the version of all the com.google.android.gms call ?