Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android build error coming from react-native-vision-camera #15

Closed
pot2mayo opened this issue Feb 15, 2022 · 2 comments
Closed

Android build error coming from react-native-vision-camera #15

pot2mayo opened this issue Feb 15, 2022 · 2 comments

Comments

@pot2mayo
Copy link

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!

@mrousavy
Copy link
Owner

Hey! I believe I fixed this, are you sure you have the latest version of VisionCamera?

@pot2mayo
Copy link
Author

pot2mayo commented Feb 15, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants