Not working react-native-firebase with expo

Hey,
I am working with React Native and created the project with CRNA and ejected with ExpoKit. I’ve followed the react-native-firebase docs while implementing into gradle files

android/app/build.gradle file:

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'
    flavorDimensions "default"

  defaultConfig {
    applicationId 'com.jul9firestoreeject'
    targetSdkVersion 25
    versionCode 1
    versionName '0.1.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')) {
        transitive = false
    }



  implementation "com.google.android.gms:play-services-base:15.0.0"
  implementation "com.google.firebase:firebase-core:15.0.2"
  implementation "com.google.firebase:firebase-database:15.0.0"
  implementation "com.google.firebase:firebase-auth:15.1.0"
  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'
  }
    compileOnly 'org.glassfish:javax.annotation:3.1.1'
  implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
  implementation 'de.greenrobot:eventbus:2.4.0'
  implementation 'com.amplitude:android-sdk:2.9.2' // Be careful when upgrading! Upgrading might break experience scoping. Check with Jesse. See Analytics.resetAmplitudeDatabaseHelper
  implementation 'com.squareup.picasso:picasso:2.5.2'
  implementation 'com.google.android.gms:play-services-gcm:15.0.1'
  implementation 'com.google.android.gms:play-services-analytics:16.0.1'
  implementation 'com.google.android.gms:play-services-maps:15.0.1'
  implementation 'com.google.android.gms:play-services-auth:15.0.1'
  implementation 'com.google.android.gms:play-services-location:15.0.1'
  implementation 'com.google.android.gms:play-services-ads:15.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"
  debugImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
  // debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
  releaseImplementation '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
    androidTestImplementation '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
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support:support-annotations:26.0.1'
    androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.0'
    androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
    androidTestImplementation 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'


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

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

android/build.gradle file:

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

buildscript {
  repositories {
    google()
    jcenter()
  }
  dependencies {
    //classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'com.android.tools.build:gradle:3.1.2'
    //classpath 'com.google.gms:google-services:3.2.0'
    classpath 'com.google.gms:google-services:3.2.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()
    google()
  }
}

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

MainApplication.java file:

package host.exp.exponent;


import com.facebook.react.ReactPackage;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import io.invertase.firebase.database.RNFirebaseDatabasePackage;
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;

public class MainApplication extends ExpoApplication {

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

  // Needed for `react-native link`
  public List<ReactPackage> getPackages() {
    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()
    );
  }

  @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;
  }
}

Though I’ve implemented as in the docs but it gives the following error


Can anyone help me how to do react-native-firebase with expo?

Thanks in advance

Hey there, I’m not exactly sure, but I searched our forums for similar topics and maybe one of these would help you?

I think one of the reasons it’s hard to find help for this error message is because Firebase has so many different modules that each have their own installation peculiarities, but this same error message seems to pop up for a ton of different articles, so it’s hard for me to tell exactly what advice would apply here.

hey @ben
thank you for your response.
I’ve already gone through those expo forums but i didn’t get any solution

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.