expo: [expo-camera & expo-face-detector] App crashing after building.

🐛 Bug Report

Environment

Native Project ( started with: react-native init )

"react": "16.8.3",
"react-native": "0.59.8",
"react-native-unimodules": "^0.5.0",
"expo-camera": "^6.0.0",
"expo-face-detector": "^6.0.0",

Steps to Reproduce

  1. Create a new project: react-native init expoCamera --version react-native@0.59.8

  2. Install React Native Unimodules following the steps in the repo: https://github.com/unimodules/react-native-unimodules/

  3. Install expo-camera following the steps in the repo: https://github.com/expo/expo/tree/master/packages/expo-camera

  4. Render <Camera> from 'expo-camera' with the prop onFacesDetected

  5. Try to run the application in Android: react-native run-android

Expected Behavior

Be able to detect faces using <Camera onFacesDetected={}>

Actual Behavior

The App crashes after is built.

Reproducible Demo

https://github.com/michaelszerman-Ripio/expoCameraTest

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (3 by maintainers)

Most upvoted comments

Confirmed: adding the firebase config fixes the crash, make sure to add a google-services.json to /app!

where should we have to add this? in which file and where can you please write in detail?

android/app directory

i have done that and now it is showing me below error

  • What went wrong:

Execution failed for task ‘:app:processDebugGoogleServices’.

No matching client found for package name ‘com.facedectorapp’

Sounds like you’ve named the Android package different to what you put in the firebase config,

Confirmed: adding the firebase config fixes the crash, make sure to add a google-services.json to /app!

@hfllr I still have this problem

I had this issue, in my case I had those logs :

08-06 21:32:26.701  2935  2935 E AndroidRuntime: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.myapp. Make sure to call FirebaseApp.initializeApp(Context) first.
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@17.0.0:234)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at com.google.firebase.ml.vision.FirebaseVision.getInstance(Unknown Source:1)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at expo.modules.facedetector.ExpoFaceDetector.createFaceDetector(ExpoFaceDetector.java:235)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at expo.modules.facedetector.ExpoFaceDetector.detectFaces(ExpoFaceDetector.java:94)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at expo.modules.camera.tasks.FaceDetectorTask.execute(FaceDetectorTask.java:40)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at expo.modules.camera.ExpoCameraView$1.onFramePreview(ExpoCameraView.java:142)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at com.google.android.cameraview.CameraView$CallbackBridge.onFramePreview(CameraView.java:604)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at com.google.android.cameraview.Camera1.onPreviewFrame(Camera1.java:766)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1203)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:108)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:166)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7529)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
08-06 21:32:26.701  2935  2935 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)

To fix this you have to setup Firebase for your app.

// android/build.gradle
...
dependencies {
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:4.3.0'
}
...
// android/app/build.gradle
...
// Bottom of the file
apply plugin: 'com.google.gms.google-services'
// MainApplication.java
import com.google.firebase.FirebaseApp;
...
@Override
  public void onCreate() {
    super.onCreate();
    FirebaseApp.initializeApp(this);
    SoLoader.init(this, /* native exopackage */ false);
  }