androidreact-nativegradlereact-native-cameracamera-view

react-native-camera build error on android


Hi I'm using the following stack: - react-native-camera 1.1.1 - react-native 0.55.3 - gradle 3.1.2

I did all the steps described in the docs for linking the project (https://github.com/react-native-community/react-native-camera).

The gradle sync ends successfully, but when I try to build the project i get a lot of errors:

/node_modules/react-native-camera/android/src/main/java/org/reactnative/camera/RNCameraView.java:15: error: package com.google.android.cameraview does not exist

import com.google.android.cameraview.CameraView;

The other errors look the same (CameraView not found)...

Here my gradle file:

dependencies {
    compile project(':react-native-video')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-languages')
    implementation project(':react-native-i18n')
    implementation project(':react-native-background-timer')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:27.+"
    implementation "com.facebook.react:react-native:+"  // From node_modules

    compile (project(':react-native-camera')) {
        compile 'com.android.support:exifinterface:27.+'
        compile ('com.google.android.gms:play-services-vision:12.0.1') {
            force = true
        }
    }
}

Thanks for your help!


Solution

  • Solved it by excluding com.android.support from react-native-camera:

    compile (project(':react-native-camera')) {
            exclude group: "com.google.android.gms"
            exclude group: "com.android.support" // --> this line
            compile 'com.android.support:exifinterface:27.+'
            compile ('com.google.android.gms:play-services-vision:12.0.1') {
                force = true
            }
        }