react-native-vision-camera: CMake Error: The following variables are used in this project, but they are set to NOTFOUND.🐛

What were you trying to do?

I have a simple RN project which utilises different libraries, one of them being the react-native-vision-camera. I am using the latest version 2.9.3. While building the project for android (both with run-android command or directly from android studio), i am getting a series of errors, whereas it was supposed to build without any issues.

Reproduceable Code

Not exactly sure, but can be reproduced in any blank app.

What happened instead?

When building on Android, with the following gradle settings:

buildToolsVersion = “30.0.2” minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 31 ndkVersion = “24.0.7856742”

… the build fails with CMAKE errors stating that some of the variables used by the project are set to NOTFOUND

Relevant log output

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:
FBJNI_LIB
linked by target "VisionCamera" in directory /Users/myuser/Documents/RN Projects/proj-v2/node_modules/react-native-vision-camera/android
FOLLY_JSON_LIB
linked by target "VisionCamera" in directory /Users/myuser/Documents/RN Projects/proj-v2/node_modules/react-native-vision-camera/android
JSI_LIB
linked by target "VisionCamera" in directory /Users/myuser/Documents/RN Projects/proj-v2/node_modules/react-native-vision-camera/android
JS_ENGINE_LIB
 linked by target "VisionCamera" in directory /Users/myuser/Documents/RN Projects/proj-v2/node_modules/react-native-vision-camera/android
REACT_NATIVE_JNI_LIB
linked by target "VisionCamera" in directory /Users/myuser/Documents/RN Projects/proj-v2/node_modules/react-native-vision-camera/android
REANIMATED_LIB
linked by target "VisionCamera" in directory /Users/myuser/Documents/RN Projects/proj-v2/node_modules/react-native-vision-camera/android

Device

On Android (Build fails on both M1 + Windows machine)

VisionCamera Version

2.9.3

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 17
  • Comments: 51 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I got it working by reading related issues #388, #338 and #513.

Same here 😕

Using version 2.15.2, react native 0.70.5 and still getting this issue.

On react native 0.70.4 it worked with these steps:

  • cd to the android folder and run ./gradlew clean
  • nuke node_modules and reinstall
  • Android Studio -> Build -> Clean Project
  • Android Studio -> File -> Invalidate Caches / Restart

But now I can’t fix it with this method anymore.

EDIT: I managed to get rid of the error by running ./gradlew assembleDebug and then could run the app in Android Studio and sync gradle once again.

I still seem to be getting this error when I refresh Gradle dependencies before building, I am using ejected Expo SDK 43 and React Native Vision v2.11.2

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: FBJNI_LIB FOLLY_JSON_LIB JS_ENGINE_LIB REACT_NATIVE_JNI_LIB REANIMATED_LIB

Updating Android Studio’s CMake version to 3.22.1 via the SDK Manager and then clean and rebuild resolved the issue for me.

0.70.3 same error

Me too, on the .70.3

CMake Warning (dev) in CMakeLists.txt:
No project() command is present.  The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command.  Add a line of
code such as....

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:
FBJNI_LIB
linked by target "VisionCamera" in directory /Users/user/Projects/bennet/node_modules/react-native-vision-camera/android
FOLLY_LIB
linked by target "VisionCamera" in directory /Users/user/Projects/bennet/node_modules/react-native-vision-camera/android
JSI_LIB
linked by target "VisionCamera" in directory /Users/user/Projects/bennet/node_modules/react-native-vision-camera/android
REACT_NATIVE_JNI_LIB
linked by target "VisionCamera" in directory /Users/user/Projects/bennet/node_modules/react-native-vision-camera/android
REANIMATED_LIB
linked by target "VisionCamera" in directory /Users/user/Projects/bennet/node_modules/react-native-vision-camera/android

disable frame processors

The biggest selling point of this library is the frame processor 🙃

Same issue

"react": "^17.0.2",
"react-native": "^0.67.0",
"react-native-reanimated": "^2.8.0",
"react-native-vision-camera": "2.13.1",
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:
FBJNI_LIB
linked by target "VisionCamera" in directory /../node_modules/react-native-vision-camera/android
FOLLY_JSON_LIB
linked by target "VisionCamera" in directory /../node_modules/react-native-vision-camera/android
JSI_LIB
linked by target "VisionCamera" in directory /../node_modules/react-native-vision-camera/android
JS_ENGINE_LIB
linked by target "VisionCamera" in directory /../node_modules/react-native-vision-camera/android
REACT_NATIVE_JNI_LIB
linked by target "VisionCamera" in directory /../node_modules/react-native-vision-camera/android
REANIMATED_LIB
linked by target "VisionCamera" in directory /../node_modules/react-native-vision-camera/android

Same here with RN 0.64.2

Same

Hey guys! I was on vacation, I’m catching up with Margelo stuff today and if I have some time left I’ll check out the issue for you. Maybe I can find a quick fix.

have react-native: 0.64.0, M1 and the same error with JSI_LIB

I fixed it after update

...
buildscript {
    ext {
        buildToolsVersion = "32.0.0"
        compileSdkVersion = 32
        targetSdkVersion = 32
        ....

This did not work for me.

Edit: This worked for me (I believe the order is important)

  1. Run ./gradlew clean in the /android directory
  2. Nuke your node_modules and install deps fresh again
  3. npx react-native run-android

This error is still happening for me on 2.10.0 (Expo SDK 44, Custom Dev Client)

Hey! I’ve rewritten the entire Android codebase of VisionCamera from CameraX to Camera2 in the efforts of ✨ VisionCamera V3.

I just now completed the Camera2 rewrite and I believe the core structure is running, but there might be some edge cases to iron out. Can you try and test the PR #1674 for me to see if you can still reproduce this issue here?

Here’s an instruction on how you can test that: https://github.com/mrousavy/react-native-vision-camera/pull/1674#issuecomment-1684104217

If the issue cannot be reproduced with that version/PR anymore, then hoorayy, I fixed it! 🎉 Otherwise please let me know and I’ll keep this issue open to keep track of it.

Thank you!

“File” -> “Invalidate Caches…” works

NOTE: This step (and hence the issue) doesn’t happen if you disable frame processors.

I was facing the same issue and I was using react-native-vision-camera 2.13.3, I upgraded it 2.13.5 and rebuild the project works good for me.

@Hirbod I finally managed to build version 2.9.4 for Android using eas build (Expo SDK 44, Dev Client). See this comment.

Let me quickly explain the problems:

Problem A

JSI_LIB (libjsi.so) is only available in React Native 0.65 (or 66?) and higher. VisionCamera relies on that, so either upgrade to React Native 0.66 or higher, or create a PR that adds support for older RN versions.

To add support for older RN versions, remove this and this, and add jsi.cpp below this line. (find the full path by browsing node modules)

Problem B

Your Gradle Version is 7.0.0 or higher. In that case, we might need to change this line:

https://github.com/mrousavy/react-native-vision-camera/blob/a54ff5782cf223cfe4bfff29c636c1dfbb1dc0ec/android/build.gradle#L469

to something like this:

    if (task.name.contains('externalNative') || task.name.contains('CMake')) {

but I haven’t tested this.

I am rolling VisionCamera in 4 production apps for clients of my app development agency (Margelo), and it works on all 4 apps. So it surely must be the older RN versions, since all of those apps are RN 0.65 and higher. I try to maintain backwards compatibility as good as I can, but I’m a single developer with 5 big open source projects to maintain, CEO at an agency and app developer - I don’t have enough time to maintain support for everything.

I would greatly appreciate PRs that fix this, and am also willing to test if a PR works in all 4 of my production apps. If it does work and does not introduce a lot of complexity just for having older RN version support, I am willing to merge it.

Same here.