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

Error when building for Android 🐛 #908

Closed
3 of 4 tasks
Altequer opened this issue Mar 15, 2022 · 27 comments · Fixed by #1466
Closed
3 of 4 tasks

Error when building for Android 🐛 #908

Altequer opened this issue Mar 15, 2022 · 27 comments · Fixed by #1466
Labels
🐛 bug Something isn't working

Comments

@Altequer
Copy link

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

@Altequer Altequer added the 🐛 bug Something isn't working label Mar 15, 2022
@Jamal-Nazzal
Copy link

Jamal-Nazzal commented Mar 16, 2022

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.

@mrousavy
Copy link
Owner

Hey!

Could you try running ./gradlew clean before the release build, see if that helps? Does it work in debug?

@Jamal-Nazzal
Copy link

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.

@Altequer
Copy link
Author

Altequer commented Mar 16, 2022

I ran it but the error remains when I generate the apk

image
image

@Jamal-Nazzal
Copy link

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.

@Altequer
Copy link
Author

If removing '_1_63_0' from the name really works, is there any way to definitively resolve this?

@Jamal-Nazzal
Copy link

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.

@jslok
Copy link

jslok commented Mar 21, 2022

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

@RafaelA977
Copy link

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

@formifan2002
Copy link

formifan2002 commented May 2, 2022

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

@Jamal-Nazzal
Copy link

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' }

@MorvanL
Copy link

MorvanL commented May 4, 2022

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

@formifan2002
Copy link

@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.

@MorvanL
Copy link

MorvanL commented May 5, 2022

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

@MorvanL
Copy link

MorvanL commented May 5, 2022

I think we can work around but there must be a problem in the build process

@MorvanL
Copy link

MorvanL commented May 5, 2022

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.

@RafaelA977
Copy link

I found a solution to solve this problem. With this patch for build.gradle it works for me:
image

@ThaJay
Copy link

ThaJay commented May 30, 2022

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.

@ThaJay
Copy link

ThaJay commented May 31, 2022

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

@ThaJay
Copy link

ThaJay commented Jun 2, 2022

@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'
}

@ThaJay
Copy link

ThaJay commented Jun 2, 2022

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",

@ThaJay
Copy link

ThaJay commented Jun 28, 2022

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)

@ThaJay
Copy link

ThaJay commented Jul 7, 2022

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.

@ApWin77
Copy link

ApWin77 commented Aug 31, 2022

Hi, @MorvanL . Have you resolved issue in your case ?

@MorvanL
Copy link

MorvanL commented Sep 9, 2022

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

@MorvanL
Copy link

MorvanL commented Sep 9, 2022

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

@MorvanL
Copy link

MorvanL commented Sep 9, 2022

it's a workaround but I confirm that it works

mrousavy added a commit that referenced this issue Sep 1, 2023
See #1376

## Breaking Changes

* Frame Processors are now **synchronous**. Previously they ran on a
separate Thread. If you want to run something on a separate Thread now,
use `runAsync` inside a Frame Processor
* Frame Processor Plugins are no longer in the global object with the
`__` prefix, but rather stored directly in the `FrameProcessorPlugins`
object exported by react-native-vision-camera. (e.g. replace
`__scanQRCodes(frame)` with `FrameProcessorPlugins.scanQRCodes(frame)`)
* `frameProcessorFps` no longer exists. Use `runAtTargetFps` inside a
Frame Processor to throttle some calls.
* `onFrameProcessorPerformanceSuggestionAvailable` no longer exists. Use
the FPS display (`enableFpsGraph={true}`) to see how your Frame
Processor performs over time. This is more in-line with how React Native
works (Dev Tools / Perf Monitor)
* VisionCamera V3 will not work on RN 0.70 or below. You need to use RN
0.71. This is because the build script got way simpler and smaller,
making it faster to build and way less error prone. Backwards
compatibility is just too complex here.
* Reanimated is no longer used as a Worklet Runtime. Instead,
VisionCamera now uses
[react-native-worklets-core](https://github.com/margelo/react-native-worklets-core).

## Progress

You can test the latest V3 release by creating a new RN project with RN
0.71 and installing VisionCamera + RNWorklets:

```sh
yarn add react-native-vision-camera@3.0.0-rc.5
yarn add react-native-worklets-core
yarn add @shopify/react-native-skia
```

Things to test:

* TensorFlow Lite plugin to load any `.tflite` model!! ✨ (see [this PR
for more
info](#1633),
will be a separate library soon)
* Drawing onto a Frame using Skia!! 🎉 
* Using `frame.toArrayBuffer()` to get the Frame's byte content in JS
* New Android build script. This should drastically speed up the build
time! 💨
* New Worklet library. This replaces Reanimated Worklets. Should be
faster and more stable :)
* New synchronous Frame Processors. Should be faster :)
* `runAtTargetFps` and `runAsync` in Frame Processors
* Using HostObjects or HostFunctions (like models from PyTorch) inside a
Frame Processor. This will probably require a few native bindings on
PyTorch's end to make the integration work (cc @raedle)

Overall V3 is close to completion. I have a few things to do the coming
days so not sure how much work I can put into this. **If anyone wants to
support the development of v3, I'd appreciate donations / sponsors:
https://github.com/sponsors/mrousavy** ❤️ :)


## Related issues 

features

- resolves
#1376
- fixes
#281
- resolves
#211
- resolves
#130
- resolves
#117
- fixes #76
- resolves
#75
- resolves
#562
- resolves
#565
- fixes
#570
- fixes
#287
- resolves
#311
- fixes
#315
- resolves
#323
- fixes
#340
- fixes
#354
- resolves
#420
- fixes
#434
- fixes
#452
- fixes
#496
- fixes
#497
- resolves
#499
- fixes
#516
- fixes
#527
- fixes
#542
- fixes
#548
- fixes
#561
- fixes
#740
- fixes
#770


...and then pretty much every Android issue lol

- fixes
#1675
(**maybe**, please test @PrernaBudhraja)
- fixes
#1671

.. maybe also (not tested):

- fixes
#1698
- fixes
#1687
- fixes
#1685
- fixes
#1681
- fixes
#1650
- fixes
#1646
- fixes
#1635
- fixes
#1631
- fixes
#1621
- fixes
#1615
- fixes
#1612
- fixes
#1605
- fixes
#1599
- fixes
#1585
- fixes
#1581
- fixes
#1569
- fixes
#1568
- fixes
#1565
- fixes
#1561
- fixes
#1558
- fixes
#1554
- fixes
#1551
- fixes
#1547
- fixes
#1543
- fixes
#1538
- fixes
#1536
- fixes
#1534
- fixes
#1528
- fixes
#1520
- fixes
#1498
- fixes
#1489
- fixes
#1477
- fixes
#1474
- fixes
#1463
- fixes
#1462
- fixes
#1449
- fixes
#1443
- fixes
#1437
- fixes
#1431
- fixes
#1429
- fixes
#1427
- fixes
#1423
- fixes
#1416
- fixes
#1407
- fixes
#1403
- fixes
#1402
- fixes
#1398
- fixes
#1396
- fixes
#1395
- fixes
#1379
- fixes
#1377
- fixes
#1374
- fixes
#1373
- fixes
#1365
- fixes
#1356
- fixes
#1353
- fixes
#1352
- fixes
#1351
- fixes
#1343
- fixes
#1340
- fixes
#1334
- fixes
#1330
- fixes
#1322
- fixes
#1296
- fixes
#1283
- fixes
#1260
- fixes
#1253
- fixes
#1251
- fixes
#1245
- fixes
#1238
- fixes
#1227
- fixes
#1226
- fixes
#1225
- fixes
#1222
- fixes
#1211
- fixes
#1208
- fixes
#1193
- fixes
#1191
- fixes
#1184
- fixes
#1164
- fixes
#1143
- fixes
#1128
- fixes
#1122
- fixes
#1120
- fixes
#1110
- fixes
#1097
- fixes
#1081
- fixes
#1080
- fixes
#1064
- fixes
#1053
- fixes
#1047
- fixes
#1044
- fixes
#1032
- fixes
#1026
- fixes
#1023
- fixes
#1015
- fixes
#1012
- fixes
#997
- fixes
#960
- fixes
#959
- fixes
#954
- fixes
#946
- fixes
#945
- fixes
#922
- fixes
#908
- fixes
#907
- fixes
#868
- fixes
#855
- fixes
#834
- fixes
#793
- fixes
#779
- fixes
#746
- fixes
#740
- fixes
#727
- fixes
#671
- fixes
#613
- fixes
#595
- fixes
#588
- fixes
#570
- fixes
#569
- fixes
#542
- fixes
#516
- fixes
#515
- fixes
#434
- fixes
#354
- fixes
#323
- fixes
#315
- fixes
#281
- fixes
#211
- fixes #76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants