react-native-vision-camera: 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?

Screenshot_1 dependencies.txt

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 27 (1 by maintainers)

Commits related to this issue

Most upvoted comments

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

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

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.

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.

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

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.

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 😕

@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”)

I’m getting this issue when building for production. In development, it builds fine.

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.