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

❓ 2.8.0 > 2.9.1 - Android build error: JSI_LIB not found #513

Closed
3 of 4 tasks
ldstein opened this issue Oct 12, 2021 · 28 comments · Fixed by #694
Closed
3 of 4 tasks

❓ 2.8.0 > 2.9.1 - Android build error: JSI_LIB not found #513

ldstein opened this issue Oct 12, 2021 · 28 comments · Fixed by #694
Labels
💭 question Further information is requested

Comments

@ldstein
Copy link

ldstein commented Oct 12, 2021

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

@ldstein ldstein added the 💭 question Further information is requested label Oct 12, 2021
@ldstein
Copy link
Author

ldstein commented Oct 12, 2021

Nevermind, looks like the cause of the issue is something else. Will investigate further.

Edit - On further testing, this issue only occurs if I switch to 2.9.0 or 2.9.1.

@ldstein ldstein closed this as completed Oct 12, 2021
@ldstein ldstein reopened this Oct 12, 2021
@Hajan39
Copy link

Hajan39 commented Oct 12, 2021

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.

@ldstein
Copy link
Author

ldstein commented Oct 12, 2021

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.

@mrousavy
Copy link
Owner

To patch this, you need to remove these:

find_library(
JSI_LIB
jsi
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)

and this:

line in your local node_modules. I'll try to figure out a way to make that CMake dependency optional...

@ldstein
Copy link
Author

ldstein commented Oct 13, 2021

Thanks for that, all good now.

@mrousavy mrousavy changed the title 2.8.0 > 2.9.1 - Android build error: JSI_LIB not found❓ ❓ 2.8.0 > 2.9.1 - Android build error: JSI_LIB not found Oct 13, 2021
@thanhnh-alobridge

This comment has been minimized.

@D4nt4lion
Copy link

Thanks for that, all good now.

In my case fixing it locally is not a good solution because many people have to develop on this app.

@xOIBrandon
Copy link

In my case fixing it locally is not a good solution because many people have to develop on this app.

@D4nt4lion Patch Package can help with that - https://www.npmjs.com/package/patch-package

@joeyfigaro
Copy link

@D4nt4lion alternatively if you're using yarn 2, you can use yarn patch react-native-vision-camera (docs)

@dahyeyudev
Copy link

dahyeyudev commented Nov 5, 2021

[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

@florcalomino
Copy link

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

@dahyeyudev
Copy link

Any update? 🥲

@byteab
Copy link

byteab commented Nov 25, 2021

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

@Hajan39
Copy link

Hajan39 commented Nov 25, 2021

@TheEhsanSarshar update to version 2.9.4 this is solved.

@byteab
Copy link

byteab commented Nov 25, 2021

Thank you so much @Hajan39

@jettandres
Copy link

jettandres commented Nov 28, 2021

The only way I was able to fix this issue was updating my react and react-native packages

"react-native": "0.66.3",
"react": "17.0.2",

I used this tool also

Make sure to follow to download the latest NDK specified via SDK manager and update your local.properties from your /android directory

@hirbod
Copy link
Contributor

hirbod commented Dec 20, 2021

Expo SDK 44, Custom Dev Client, I get:
Version: 2.10.0

* What went wrong:
Execution failed for task ':react-native-vision-camera:generateJsonModelDebug'.
> /myapp//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 /myapp//node_modules/react-native-vision-camera/android

@geoffreyLB
Copy link

still have error when building for Android, any update ?

@mark-hayward
Copy link

I am still getting this error too.

@laogui
Copy link

laogui commented Mar 2, 2022

I am still getting this error too.

react-native-vision-camera 2.12.1
react-native 0.66.5.
enabled hermes.

@StationSoen
Copy link

StationSoen commented Mar 15, 2022

I met this kind of Error and solved it by uninstall and reinstall react-native-vision-camera.

"react-native-vision-camera": "^2.12.2",
"react-native": "0.67.2",
hermes enabled

* What went wrong:
Execution failed for task ':react-native-vision-camera:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process /Users/sunghyun/Library/Android/sdk/cmake/3.10.2.4988404/bin/ninja with arguments {-C /Users/sunghyun/Desktop/Roubit/pipit_app/node_modules/react-native-vision-camera/android/.cxx/cmake/debug/armeabi-v7a VisionCamera}
  ninja: Entering directory `/Users/sunghyun/Desktop/Roubit/pipit_app/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/VisionCameraScheduler.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 

@mrousavy
Copy link
Owner

Can you paste more log output? There's no error here.

Maybe try cleaning everything and making sure your NDK and CMake is installed correctly via Android Studio

@StationSoen
Copy link

Can you paste more log output? There's no error here.

Maybe try cleaning everything and making sure your NDK and CMake is installed correctly via Android Studio

Cleaning everything (re-install library) works!

thanks for great library! 😁

@mrousavy
Copy link
Owner

Awesome, nice to hear!

@GSFZamai
Copy link

[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 iOS compiled with success. But in android I'm getting both error, like you. With or without the patch fix

@mrousavy
Copy link
Owner

Which RN versions are you on? Compare your versions with the Example/ app here

@GSFZamai
Copy link

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.

@lfabl
Copy link

lfabl commented Jul 7, 2023

You must only install C++ sdk to your pc.

For x64: here
For x86: here

and do the following processes respectively:

  • delete node_modules directory.
  • delete android/build directory.
  • delete android/.gradle directory.
  • delete android/app/build directory
    then
  • run "yarn ios" or "yarn android" command. ( run the project. )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💭 question Further information is requested
Projects
None yet