Android app keeps closing after import expo-firebase-auth

Hi, I followed the tutorial here: https://github.com/EvanBacon/expo-native-firebase

Added firebase-app (core) successfully. But when I tried to add expo-firebase-auth, the app just kept closing itself.

I found there’s an extra point in the instruction:

And it directed me to: https://rnfirebase.io/docs/master/auth/android#Install-the-RNFirebase-Authentication-package

And I did paste the code but it won’t work. Any idea how I should fix step three?

Thank you very much.

Leo

Yeah those docs have changed unfortunately.

Android

  1. Append the following lines to android/settings.gradle:

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

    and if not already included

    include ':expo-core'
    project(':expo-core').projectDir = new File(rootProject.projectDir, '../node_modules/expo-core/android')
    
    include ':expo-firebase-app'
    project(':expo-firebase-app').projectDir = new File(rootProject.projectDir, '../node_modules/expo-firebase-app/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

    api project(':expo-firebase-auth')
    

    and if not already included

    api project(':expo-core')
    api project(':expo-firebase-app')
    
  3. Some Unimodules are not included in the default ExpoKit suite, these modules will needed to be added manually. If your Android build cannot find the Native Modules, you can add them like this: ./android/app/src/main/java/host/exp/exponent/MainActivity.java

/*
 * At the top of the file.
 * This is automatically imported with Android Studio, but if you are in any other editor you will need to manually import the module.
*/
import expo.modules.firebase.app.FirebaseAppPackage; // This should be here for all Expo Firebase features.
import expo.modules.firebase.auth.FirebaseAuthPackage;

// Later in the file...

@Override
public List<Package> expoPackages() {
  // Here you can add your own packages.
  return Arrays.<Package>asList(
    new FirebaseAppPackage(), // This should be here for all Expo Firebase features.
    new FirebaseAuthPackage() // Include this.
  );
}

Hi, thanks for the reply, but I still get the force closing error on Android if I imported expo-firebase-auth. Here’s my files:

Right now I commented out all firebase-auth imports. As long as I uncomment them, the app force close.

https://gist.github.com/sillyleo/711c49a14fb7e45346bcdfd3585e3764

Could you take a look please? Especially the MainActivity.java. I don’t really know what weng wrong. It’s a fresh new expo init project just with firebase import.

My package.json is clean, and iOS runs fine, so it must be something on the Android side.

{
  "name": "empty-project-template",
  "main": "node_modules/expo/AppEntry.js",
  "private": true,
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "^30.0.1",
    "expo-firebase-app": "^1.0.0-rc.1",
    "expo-firebase-auth": "^1.0.0-rc.1",
    "expokit": "1.7.1",
    "react": "16.3.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz"
  }
}

Found the crash was caused by this:

java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.IllegalArgumentException: Given String is empty or null

But have no idea why…

See the trouble shooting: https://github.com/expo/expo/tree/master/packages/expo-firebase-auth

Got it. Solved. Thanks.

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