react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.๐Ÿ›

Open arn3342 opened this issue 4 years ago โ€ข 37 comments

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

arn3342 avatar Nov 15 '21 12:11 arn3342

Same here :/

dragma avatar Nov 15 '21 14:11 dragma

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

mAdutskevich avatar Nov 16 '21 06:11 mAdutskevich

Same

ToJuHB avatar Nov 16 '21 15:11 ToJuHB

Same here with RN 0.64.2

jackstudd avatar Nov 17 '21 06:11 jackstudd

Same error with RN 0.65.1 and react-native-vision-camera 2.9.3

Intel based Mac

  buildToolsVersion = "30.0.2"
  minSdkVersion = 21
  compileSdkVersion = 30
  targetSdkVersion = 30
  ndkVersion = "20.1.5948944"
  playServicesVersion = "17.0.0" //google maps
  androidMapsUtilsVersion = "2.2.6" //google maps
  //Only using Android Support libraries
  supportLibVersion = "28.0.0"

swizes avatar Nov 17 '21 22:11 swizes

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

  • I deleted my node_modules folder
  • I ran yarn install
  • cd android
  • ./gradlew clean
  • ./gradlew assembleDebug
  • I was then confronted with the same issue in #513, so I followed this : https://github.com/mrousavy/react-native-vision-camera/issues/513#issuecomment-940857627
  • It all worked! Sometimes sync fails in Android Studio, displaying no error, but within a terminal it works just fine.

jackstudd avatar Nov 18 '21 06:11 jackstudd

I am experiencing this also, any updates as to when an official fix may get published?

Sewb21 avatar Dec 07 '21 14:12 Sewb21

Same here.

brunofrigeri avatar Dec 07 '21 20:12 brunofrigeri

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.

mrousavy avatar Dec 08 '21 14:12 mrousavy

Upgrading from react-native 0.64.2 -> 0.66.3 and following the guide from @JackStudd worked for me!

willcray avatar Dec 08 '21 20:12 willcray

I am using Expo SDK 43 so upgrading React Native versions isn't an option, unfortunately. The fixes for adding older support doesn't work either, I will keep an eye on the issue. Are there any older, stable versions of the package that work with React Native 0.64?

Sewb21 avatar Dec 15 '21 12:12 Sewb21

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

hirbod avatar Dec 20 '21 01:12 hirbod

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

sandlands avatar Dec 24 '21 14:12 sandlands

I should've commented this earlier. I am on RN 0.66.2 so the assumption that my RN being of an old version is causing this issue is wrong! I did try the workoarounds mentioned in other threads but nothing seem to work properly. Sometimes even if the build succeeds, the application crashes on launch on Android (somehow it works on iOS, but i only tested on emulator)

arn3342 avatar Dec 27 '21 03:12 arn3342

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

Sewb21 avatar Jan 05 '22 09:01 Sewb21

same issue

jhoanborges avatar Mar 17 '22 06:03 jhoanborges

Same here

AdamSheaHewett avatar May 07 '22 12:05 AdamSheaHewett

Same issue here.

"react": "17.0.2",
"react-native": "0.65.1",
"react-native-reanimated": "^2.2.0",
"react-native-vision-camera": "2.10.0",

faustaleonardo avatar May 20 '22 07:05 faustaleonardo

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

dittmarconsulting avatar May 26 '22 00:05 dittmarconsulting

Same issue

"react": "^17.0.2",
"react-native": "0.68.2",
"react-native-reanimated": "2.5.0",
"react-native-vision-camera": "^2.13.3",

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 C:/Users/mauro.a.russo/Documents/projects/react-native/COIMA/node_modules/react-native-vision-camera/android FOLLY_JSON_LIB linked by target "VisionCamera" in directory C:/Users/mauro.a.russo/Documents/projects/react-native/COIMA/node_modules/react-native-vision-camera/android JSI_LIB linked by target "VisionCamera" in directory C:/Users/mauro.a.russo/Documents/projects/react-native/COIMA/node_modules/react-native-vision-camera/android JS_ENGINE_LIB linked by target "VisionCamera" in directory C:/Users/mauro.a.russo/Documents/projects/react-native/COIMA/node_modules/react-native-vision-camera/android REACT_NATIVE_JNI_LIB linked by target "VisionCamera" in directory C:/Users/mauro.a.russo/Documents/projects/react-native/COIMA/node_modules/react-native-vision-camera/android REANIMATED_LIB linked by target "VisionCamera" in directory C:/Users/mauro.a.russo/Documents/projects/react-native/COIMA/node_modules/react-native-vision-camera/android

maurorusso002 avatar Jun 06 '22 14:06 maurorusso002

Same issue with RN 0.68.2 Any update @mrousavy ?

zienna avatar Jun 08 '22 22:06 zienna

@mrousavy Same issue in RN 0.68.1

praveenbalajia avatar Jun 09 '22 12:06 praveenbalajia

Can we please reopen this issue @mrousavy? There are now 8 people with the same issue.

dittmarconsulting avatar Jun 10 '22 00:06 dittmarconsulting

Thank you @mrousavy ๐Ÿ™

dittmarconsulting avatar Jun 15 '22 00:06 dittmarconsulting

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.

PankajPunia avatar Jun 16 '22 02:06 PankajPunia

Can confirm with @PankajPunia. Upgrading to version 2.13.5 fixed this issue for me.

lundjrl avatar Jun 20 '22 15:06 lundjrl

Whatโ€™s your react-native version @PankajPunia ? I did as you but it doesnโ€™t work

ApWin77 avatar Jun 22 '22 11:06 ApWin77

@ApWin77
"react": "17.0.2", "react-native": "0.67.4"

PankajPunia avatar Jun 24 '22 04:06 PankajPunia

Getting this issue with 2.13.5 and RN 0.68.1

tgreco avatar Jul 02 '22 17:07 tgreco

Getting this issue with 2.13.5 and RN 0.68.1

alexdarh avatar Jul 05 '22 11:07 alexdarh