package.js
...
"react": "16.8.3",
"react-native": "0.59.5",
"react-native-camera": "git+https://git@github.com/react-native-community/react-native-camera.git"
...
settings.gradle
include ':app'
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
settings.gradle
...
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "xxxxxx"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
...
}
dependencies {
implementation project(':react-native-camera')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.annotation:annotation:1.0.2'
implementation "com.facebook.react:react-native:+" // From node_modules
}
...
gradle.properdies
android.useAndroidX=true
android.enableJetifier=true
Error
../../../../../../../../node_modules/react-native-camera/android/src/main/java/com/google/android/cameraview/Camera2.java (3 errors)
error: cannot find symbol class NonNull error: cannot find symbol class NonNull error: cannot find symbol class NonNull
this problem is caused by google migrating to androidx
A first quick-fix would be to delete the imports / annotation by hand in your /node-modules/
You need to :
import android.support.annotation.NonNull;
line and delete it Mike Hardy created a package allowing you to do this automatically : https://github.com/mikehardy/jetifier#to-jetify--convert-node_modules-dependencies-to-androidx (it's react-native / npm friendly)
You will need to do this for every packages if they are using those annotations.
Also keep in mind that some packages might be using java classes located at : android.support.v4
(such as ActivityCompat, NotificationCompat, ...) those classes are now located here androidx.core.app.*
(androidx.core.app.ActivityCompat, ...) due to the androidx migration
Some references :
Here is a class mapping csv file between old / new android imports :
https://github.com/mikehardy/jetifier/blob/master/src/androidx-class-mapping.csv