react-native-vision-camera: ❓ 2.8.0 > 2.9.1 - Android build error: JSI_LIB not found

Question

Hi,

I’m attempting to upgrade from RNVC 2.8 > 2.9 and hitting a build error:

Execution failed for task ':react-native-vision-camera:generateJsonModelDebug'.
> C:\dev\MeshMobile\node_modules\react-native-vision-camera\android\CMakeLists.txt : C/C++ debug|arm64-v8a : CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
  Please set them or make sure they are set and tested correctly in the CMake files:
  JSI_LIB
      linked by target "VisionCamera" in directory C:/dev/MeshMobile/node_modules/react-native-vision-camera/android

Observations:

  • No problems with 2.8.xx.
  • Seems to only affect 2.9.0 and 2.9.1
  • I’m not seeing this error when building the example app
  • Affecting multiple projects (all based on boilerplate provided by npx react-native init ProjectName)

Repo+branch demonstrating the issue here

Full Build Log: rnvc2.9.1-build-error.log

The offending CMakeLists.txt: ~\node_modules\react-native-vision-camera\android\CMakeLists.txt

I’m stumped. Any thoughts on what I’m doing wrong?

What I tried

  • Read the install instructions
  • Tested all releases of RNVC from 2.8.0 onwards
  • Enable/disable hermes in build.gradle
  • Set compileSdkVersion to 31
  • Set targetSdkVersion to 31
  • Add android:exported to main activity
  • cd android && gradlew clean
  • Build via npm run android and Android Studio

VisionCamera Version

2.9.0 and 2.9.1

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 28 (5 by maintainers)

Most upvoted comments

Any update on this issue? Still doesn’t work on Android.

@TheEhsanSarshar update to version 2.9.4 this is solved.

here is the juicy part about this error

error: redefinition of 'JHashMap'

here is the full error

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
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

[android, didn’t check iOS] I’m getting same issue even I tried that patch solutions… Where should I fix?

//package.json
 "react-native": "^0.64.2",
 "react-native-gesture-handler": "^1.10.3",
 "react-native-reanimated": "^2.2.3",
 "react-native-scan-barcode": "^3.1.5",
 "react-native-vision-camera": "^2.9.3",
//build.gradle
buildscript {
    ext {
        buildToolsVersion = "29.0.3"
        minSdkVersion = 26
        compileSdkVersion = 31
        targetSdkVersion = 31
    }
}

errors in terminal with patch package solution

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-vision-camera:externalNativeBuildDebug'.
> Build command failed.
 Error while executing process /Users/yudahye/Library/Android/sdk/cmake/3.10.2.4988404/bin/ninja with arguments {-C /Users/projectName/node_modules/react-native-vision-camera/android/.cxx/cmake/debug/armeabi-v7a VisionCamera}
 ninja: Entering directory `/Users/projectName/node_modules/react-native-vision-camera/android/.cxx/cmake/debug/armeabi-v7a'
 [1/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JHashMap.cpp.o
 [2/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JImageProxy.cpp.o
 [3/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessorPlugin.cpp.o
 [4/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/CameraView.cpp.o
 [5/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/JSIJNIConversion.cpp.o
 FAILED: CMakeFiles/VisionCamera.dir/src/main/cpp/JSIJNIConversion.cpp.o 
 
 ~~
   In file included from ../../../../src/main/cpp/JSIJNIConversion.cpp:15:
 In file included from /Users/projectName/android/../node_modules/react-native/ReactAndroid/src/main/jni/react/jni/NativeMap.h:11:
 ../../../../build/third-party-ndk/folly/folly/dynamic.h:63:10: fatal error: 'boost/operators.hpp' file not found
 #include <boost/operators.hpp>
          ^~~~~~~~~~~~~~~~~~~~~
 1 error generated.
 [6/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraScheduler.cpp.o
 [7/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/FrameProcessorRuntimeManager.cpp.o
 FAILED: CMakeFiles/VisionCamera.dir/src/main/cpp/FrameProcessorRuntimeManager.cpp.o 
 
 ~~
 BUILD FAILED in 19s

   at makeError (/Users/projectName/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
   at /Users/projectName/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
   at processTicksAndRejections (internal/process/task_queues.js:93:5)
   at async runOnAllDevices (/Users/projectName/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
   at async Command.handleAction (/Users/projectName/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)

errors without patch package solution

* What went wrong:
Execution failed for task ':react-native-vision-camera:generateJsonModelDebug'.
> /Users/yudahye/today/todaypickup_partners/node_modules/react-native-vision-camera/android/CMakeLists.txt : C/C++ debug|armeabi-v7a : CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
  Please set them or make sure they are set and tested correctly in the CMake files:
  JSI_LIB
      linked by target "VisionCamera" in directory /Users/yudahye/today/todaypickup_partners/node_modules/react-native-vision-camera/android

In previous issues, there was a bug that 2.9.0/2.9.1 was working only with RN 66, but RN 66 currently doesn’t work with the current version react-native-reanimated.

I’m on RN 0.64.2. After i saw this issue #957 , I’ve updated the library to v2.13.0 and worked on Android. But for now, I need to use v2.10.0 for iOS builds (with XCode 12) #716 and v 2.13.0 for android.

I’ll try to build with v2.13.0 in iOS with XCode 13.

Thank you so much @Hajan39

Thanks for the tip @Hajan39 , didn’t see that.

Downgrading react-native-reanimated to 2.3.0-beta.2 got me past the build error.