react-native-vision-camera
react-native-vision-camera copied to clipboard
Error when building for Android 🐛
What were you trying to do?
Whenever I go to build, an error occurs saying that the file is missing. I've tested with other versions but still. Could anyone help?
Reproduceable Code
gradlew assembleRelease
What happened instead?
Relevant log output
The following error always occurs:
C/C++: ../../../../build/third-party-ndk/folly\folly/dynamic.h:63:10: fatal error: 'boost/operators.hpp' file not found
Device
Android
VisionCamera Version
2.12.2
Additional information
- [ ] I am using Expo
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar issues in this repository and found none.
I'm facing the same issue
../../../../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.
[9/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/CameraView.cpp.o
ninja: build stopped: subcommand failed.
Hey!
Could you try running ./gradlew clean before the release build, see if that helps? Does it work in debug?
When I try this: go to \node_modules\react-native-vision-camera\android\build\third-party-ndk I find the boost folder named "boost_1_63_0", I rename it to just "boost". the build works, but this time I get the following error in the react-native start terminal
throw ex;
^
Error: EPERM: operation not permitted, lstat '[project directory]\node_modules\react-native-vision-camera\android\build\intermediates\cxx\Debug\4x231b5p\obj\arm64-v8a\libVisionCamera.so.tmp2ab35ca'
Emitted 'error' event on NodeWatcher instance at:
at NodeWatcher.<anonymous> ([project directory]\node_modules\sane\src\node_watcher.js:291:16)
at FSReqCallback.oncomplete (node:fs:198:21) {
errno: -4048,
code: 'EPERM',
syscall: 'lstat',
path: '[project directory]\\node_modules\\react-native-vision-camera\\android\\build\\intermediates\\cxx\\Debug\\4x231b5p\\obj\\arm64-v8a\\libVisionCamera.so.tmp2ab35ca'
}
and if I delete the build and .cxx folders, then start clean cache, it builds fine but again crashes if I rebuild.
I ran it but the error remains when I generate the apk

Please check my comment above. inside \node_modules\react-native-vision-camera\android\build\third-party-ndk there is a folder that should be named boost for some reason it gets named boost_1_63_0 that's why boost/operators.hpp can't be found.
If you rename it to the correct name boost the error goes away. that's not a solution AT ALL, I'm posting this to make you aware of the source of the problem.
If removing '_1_63_0' from the name really works, is there any way to definitively resolve this?
the first time visionCamera builds it installs this library https://github.com/react-native-community/boost-for-react-native something wrong happens there. sometimes it builds fine and creates a folder called boost, other times it names it boost_1_63_0 and as a result boost/operators.hpp can't be found. Can't be clearer than this honestly. can this be definitively resolved? I don't know, mrousavy might be able to solve it.
I'm getting this issue when building for production. In development, it builds fine.
Same issue for me. Vision camera download "boost_${BOOST_VERSION}.tar.gz" from github, unzip it.
After that, in doLast block of the prepareBoost task renames the file to boost:

but the file is not renamed for some reason. So we got "'boost/operators.hpp' file not found" error.
Manually rename folder after first build works for me
@RafaelA977 found the problem in the build.gradle file (see above). The reason is, that gradle cannot rename the directory (from boost_1_63_0 to boost). For more details see gradle documentation "Gradle has no API for moving files and directories around, but you can use the Apache Ant integration to easily do that"
https://docs.gradle.org/current/userguide/working_with_files.html#sec:moving_files_example
Solution:
Comment (or remove) the line
//file("$thirdPartyNdkDir/boost_${BOOST_VERSION}").renameTo("$thirdPartyNdkDir/boost")
and replace it with
ant.move(file: "$thirdPartyNdkDir/boost_${BOOST_VERSION}", tofile: "$thirdPartyNdkDir/boost", quiet: "false")
Now I'm getting this error
Error: EPERM: operation not permitted, lstat 'C:\Users\...\app\node_modules\react-native-vision-camera\android\build\intermediates\cxx\Debug\602l1f37\obj\arm64-v8a\libVisionCamera.so.tmp50c975e' Emitted 'error' event on NodeWatcher instance at: at NodeWatcher.<anonymous> (C:\Users\...\app\node_modules\sane\src\node_watcher.js:291:16) at FSReqCallback.oncomplete (node:fs:198:21) { errno: -4048, code: 'EPERM', syscall: 'lstat', path: 'C:\\Users\\...\\app\\node_modules\\react-native-vision-camera\\android\\build\\intermediates\\cxx\\Debug\\602l1f37\\obj\\arm64-v8a\\libVisionCamera.so.tmp50c975e' }
Hello ! I have a similar error with folly and I think that is the same : node_modules/react-native/ReactCommon/cxxreact/CxxModule.h:15:10: fatal error: 'folly/dynamic.h' file not found
I needed to disable FrameProcessors to build (https://mrousavy.com/react-native-vision-camera/docs/guides/frame-processors/#android) but we will soon need frame processors :/
@MorvanL: before first correct "gradlew build" you must (!) run a "gradlew clean". Otherwise the gradlew build might not process correctly since some parts (e.g. folly...tar.gz) have been downloaded already during earlier builds and will not be processed correctly. Check after the clean and before the build, if directory "react-native-vision-camera\android\build" is empty. If not, delete any content in the directory manually and start the build.
@formifan2002 I did some tests:
If I only run gradlew assembleRelease it works.
When I run gradlew clean assembleRelease I have : success, failed, success, failed, ....
But if I run gradlew clean then gradlew assembleRelease it works.
However in both cases I could see that the "react-native-vision-camera\android\build" file is correctly deleted
On our CI using fastlane and running gradlew clean assembleRelease, it fails every time. May be because there is more clean and yarn install between each build (i don't know details of our CI)
I think we can work around but there must be a problem in the build process
Sorry for spam.
When it fails I don't have the lib folly in the react-native-vision-camera/android/build/third-party-ndk folder
I have only hermes and jsc folder.
I found a solution to solve this problem. With this patch for build.gradle it works for me:

Getting the following error with version 2.13.3:
Error: ENOENT: no such file or directory, lstat '/Users/dev/app/node_modules/react-native-vision-camera/android/build/third-party-ndk/boost_1_63_0
Emitted 'error' event on FSEventsWatcher instance at:
at Walker.emit (node:events:526:28)
at /Users/dev/app/node_modules/walker/lib/walker.js:52:12
at FSReqCallback.oncomplete (node:fs:198:21) {
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '/Users/dev/app/node_modules/react-native-vision-camera/android/build/third-party-ndk/boost_1_63_0'
}
There is a folder .../node_modules/react-native-vision-camera/android/build/third-party-ndk/boost/boost
How can I build the production version without error?
I have been working on the development build including frame processors no problem.
If I rename the first folder boost to boost_1_63_0, I get the following error:
In file included from /Users/dev/app/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>
^~~~~~~~~~~~~~~~~~~~~
@RafaelA977 Was it too much trouble to copy the text?
eachFile { fname -> fname.path = (fname.path - "boost_${BOOST_VERSION}/")}
into("$thirdPartyNdkDir/boost")
After applying your patch, I get another error:
> Task :app:bundleReleaseJsAndAssets FAILED
/Users/dj/dev/chipta/scan-app/node_modules/metro-hermes-compiler/src/emhermesc.js:77
throw ex;
^
Error: ENOENT: no such file or directory, lstat '/Users/dev/app/node_modules/react-native-vision-camera/android/.cxx/cmake/release/armeabi-v7a/CMakeFiles/CMakeTmp/CMakeFiles/TargetDirectories.txt'
Emitted 'error' event on FSEventsWatcher instance at:
at Walker.emit (node:events:526:28)
at /Users/dev/app/node_modules/walker/lib/walker.js:52:12
at FSReqCallback.oncomplete (node:fs:198:21) {
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '/Users/dev/app/node_modules/react-native-vision-camera/android/.cxx/cmake/release/armeabi-v7a/CMakeFiles/CMakeTmp/CMakeFiles/TargetDirectories.txt'
}
I went ahead and tried older versions. 2.13.1 is the latest version that builds for me.
"react-native-vision-camera": "2.13.1",
I don't know why but today I got the error on 2.13.1 but on the latest version (2.13.5) it builds production just fine.
(I did nuke my node_modules folder and cleaned my Gradle build files on both versions)
For some reason it did not build any more but weirdly enough the latest version (2.13.5) did work this time. This confuses me but I'm glad it works.
Hi, @MorvanL . Have you resolved issue in your case ?
Hi, sorry @ApWin77 I just saw your message.
Until now we didn't need the frame processor so we disabled them. But now we need them for our barcode scanner and according to my first tests the problem is still there. It seems that doing gradlew clean before gradlew assembleRelease does not solve the problem anymore. I haven't tested the patch described above, but is there any chance that the problem will be fixed?
We use RN 0.69.4 and I tried with and without Hermes enable
Oh my bad, seems working with gradlew clean before gradlew assembleRelease (and not gradlew clean assembleRelease together).
But I have to test with our CI and for the moment I have another error. I'll let you know once I've tested everything
it's a workaround but I confirm that it works