Android build error coming from react-native-vision-camera
pot2mayo opened this issue · comments
David Cochard commented
Hi
I was trying to build the example code from this repo and got the following error which seems to come from the react-native-vision-camera
module
> Task :react-native-vision-camera:externalNativeBuildDebug
Build VisionCamera_armeabi-v7a
ninja: Entering directory `Z:\Projects\vision-camera-image-labeler\example\node_modules\react-native-vision-camera\android\.cxx\cmake\debug\armeabi-v7a'
In file included from ../../../../src/main/cpp/java-bindings/JHashMap.cpp:5:
../../../../src/main/cpp/java-bindings/JHashMap.h:16:8: error: redefinition of 'JHashMap'
../../../../build/fbjni-0.3.0-headers.jar\fbjni/detail/Iterator.h:170:8: note: previous definition is here
../../../../src/main/cpp/java-bindings/JHashMap.cpp:15:43: error: redefinition of 'create'
../../../../build/fbjni-0.3.0-headers.jar\fbjni/detail/Iterator-inl.h:230:42: note: previous definition is here
In file included from ../../../../src/main/cpp/JSIJNIConversion.cpp:25:
../../../../src/main/cpp/java-bindings/JHashMap.h:16:8: error: redefinition of 'JHashMap'
../../../../build/fbjni-0.3.0-headers.jar\fbjni/detail/Iterator.h:170:8: note: previous definition is here
> Task :react-native-vision-camera:externalNativeBuildDebug FAILED
61 actionable tasks: 10 executed, 51 up-to-date
FAILURE: Build failed with an exception.
and futher in the error stack
../../../../src/main/cpp/java-bindings/JHashMap.h:16:8: error: redefinition of 'JHashMap'
struct JHashMap : JavaClass<JHashMap<K, V>, JMap<K, V>> {
^
../../../../build/fbjni-0.3.0-headers.jar\fbjni/detail/Iterator.h:170:8: note: previous definition is here
struct JHashMap : JavaClass<JHashMap<K, V>, JMap<K, V>> {
^
1 error generated.
[8/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCamera.cpp.o
[9/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/FrameProcessorRuntimeManager.cpp.o
ninja: build stopped: subcommand failed.
Any known compatibility issue between this example app and the source module?
Thanks!
Marc Rousavy commented
Hey! I believe I fixed this, are you sure you have the latest version of VisionCamera?
David Cochard commented
I could actually solve my issue by updating to the latest react-native-vision-camera
package version 2.12.0.
I also needed to fix a few more build settings on android.
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -14,6 +14,7 @@
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
+ android:exported="true"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 6165d24..6b6636d 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -3,8 +3,8 @@
buildscript {
ext {
minSdkVersion = 21
- compileSdkVersion = 30
- targetSdkVersion = 30
+ compileSdkVersion = 31
+ targetSdkVersion = 31
ndkVersion = "20.1.5948944"
}
repositories {
diff --git a/example/package.json b/example/package.json
index 850c7a3..f0d2a16 100644
--- a/example/package.json
+++ b/example/package.json
@@ -12,7 +12,7 @@
"react": "17.0.1",
"react-native": "^0.64.2",
"react-native-reanimated": "^2.3.0-alpha.2",
- "react-native-vision-camera": "^2.6.1"
+ "react-native-vision-camera": "^2.12.0"
},
"devDependencies": {
"@babel/core": "^7.15.0",
Thanks!