my space

Expo Camera set up in Bare workflow

react-nativeexpoexpo-camera

May 11, 2020

Found a difficulty when I tried to eject an app with expo-camera from Expo Managed into Bare workflow. Our team managed to solve this problem and I blog it as a reference

From my experience, it’s simple to use most of expo component in the Bare workflow until I come across expo-camera. I expected it to be managed by react-native-unimodules. However, thing wasn’t that simple. This is the error I observed during gradle build:

ERROR: Failed to resolve: com.google.android:cameraview:1.0.0
Show in Project Structure dialog
Affected Modules: app

This can be fixed by applying this into build.gradle

allprojects {
    repositories {
        ...your code
        maven {
            // expo-camera bundles a custom com.google.android:cameraview
            url "$rootDir/../node_modules/expo-camera/android/maven"
        }
    }
}

and you’re good to go!

The hardest part is the above hasn’t been stated in the component reference. But it’s located deeply in its github repo here https://github.com/expo/expo/tree/sdk-36/packages/expo-camera


gie

Written by gie who lives and works in Bangkok. Build things by code.
my twitter | github