react-native-vision-camera: 🐛 Android build fails on CI

What were you trying to do?

Tried to have the 2.5.0 build Android on CI (Bitrise). Have to mention this is the first time trying to build react-native-vision-camera on CI. IOS builds went fine.

What happened instead?

Build fails with: ninja: error: '../../../../build/third-party-ndk/hermes/jni/armeabi-v7a/libhermes.so', needed by '../../../../build/intermediates/cmake/release/obj/armeabi-v7a/libVisionCamera.so', missing and no known rule to make it

Doesn’t like relative paths?

Relevant log output

> Task :react-native-vision-camera:generateJsonModelRelease
/Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt : C/C++ release[REDACTED]armeabi-v7a : CMake Warning at /Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt:122 (message):
  VisionCamera linking: FOR_HERMES=true
/Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt : C/C++ release[REDACTED]armeabi-v7a : CMake Warning at /Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt:122 (message):
  VisionCamera linking: FOR_HERMES=true
/Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt : C/C++ release[REDACTED]arm64-v8a : CMake Warning at /Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt:122 (message):
  VisionCamera linking: FOR_HERMES=true
/Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt : C/C++ release[REDACTED]arm64-v8a : CMake Warning at /Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt:122 (message):
  VisionCamera linking: FOR_HERMES=true
/Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt : C/C++ release[REDACTED]x86 : CMake Warning at /Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt:122 (message):
  VisionCamera linking: FOR_HERMES=true
/Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt : C/C++ release[REDACTED]x86 : CMake Warning at /Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt:122 (message):
  VisionCamera linking: FOR_HERMES=true
/Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt : C/C++ release[REDACTED]x86_64 : CMake Warning at /Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt:122 (message):
  VisionCamera linking: FOR_HERMES=true
/Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt : C/C++ release[REDACTED]x86_64 : CMake Warning at /Users/vagrant/git/node_modules/react-native-vision-camera/android/CMakeLists.txt:122 (message):
  VisionCamera linking: FOR_HERMES=true
> Task :react-native-vision-camera:prepareHermes UP-TO-DATE
> Task :react-native-vision-camera:prepareJSC
> Task :react-native-vision-camera:createNativeDepsDirectories UP-TO-DATE
> Task :react-native-vision-camera:downloadBoost
Download https://github.com/react-native-community/boost-for-react-native/releases/download/v1.63.0-0/boost_1_63_0.tar.gz
> Task :react-native-vision-camera:prepareBoost
> Task :react-native-vision-camera:downloadDoubleConversion
Download https://github.com/google/double-conversion/archive/v1.1.6.tar.gz
> Task :react-native-vision-camera:prepareDoubleConversion
> Task :react-native-vision-camera:downloadFolly
Download https://github.com/facebook/folly/archive/v2020.01.13.00.tar.gz
> Task :react-native-vision-camera:prepareFolly
> Task :react-native-vision-camera:downloadGlog
Download https://github.com/google/glog/archive/v0.3.5.tar.gz
> Task :react-native-vision-camera:prepareGlog
> Task :react-native-vision-camera:prepareThirdPartyNdkHeaders
> Task :react-native-vision-camera:externalNativeBuildRelease FAILED
Build VisionCamera_armeabi-v7a
ninja: Entering directory `/Users/vagrant/git/node_modules/react-native-vision-camera/android/.cxx/cmake/release/armeabi-v7a'
ninja: error: '../../../../build/third-party-ndk/hermes/jni/armeabi-v7a/libhermes.so', needed by '../../../../build/intermediates/cmake/release/obj/armeabi-v7a/libVisionCamera.so', missing and no known rule to make it
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-vision-camera:externalNativeBuildRelease'.
> Build command failed.
  Error while executing process /usr/local/share/android-sdk/cmake/3.10.2.4988404/bin/ninja with arguments {-C /Users/vagrant/git/node_modules/react-native-vision-camera/android/.cxx/cmake/release/armeabi-v7a VisionCamera}
  ninja: Entering directory `/Users/vagrant/git/node_modules/react-native-vision-camera/android/.cxx/cmake/release/armeabi-v7a'
  
  ninja: error: '../../../../build/third-party-ndk/hermes/jni/armeabi-v7a/libhermes.so', needed by '../../../../build/intermediates/cmake/release/obj/armeabi-v7a/libVisionCamera.so', missing and no known rule to make it
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 11m 55s
651 actionable tasks: 651 executed
Build task failed, error: exit status 1

Device

Default Bitrise build (Xcode 12.4.x, on macOS 10.15.7 (Catalina))

VisionCamera Version

2.5.0

Additional information

About this issue

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

Most upvoted comments

Oh yeah, 2.9.0 currently only works on RN 0.66. Will fix this to also work on older RN versions when I find some time on the weekend!

@Kypsis A solution that I found, more like a workaround was putting all the gradle tasks related to the building process of vision camera into a single script on package.json and running it before the Ci build, like so:

"android:prepareNativeDeps": "cd android && ./gradlew :react-native-vision-camera:prepareJSC && ./gradlew :react-native-vision-camera:prepareHermes && ./gradlew :react-native-vision-camera:extractJNIFiles && ./gradlew :react-native-vision-camera:extractAARHeaders && ./gradlew :eact-native-vision-camera:prepareThirdPartyNdkHeaders"

And then you can include the yarn android:prepareNativeDeps on your CI pipeline

This solves the issue of the libhermes.so file not being available at the time when libCameraVision.so needs it. The only problem with that (I haven’t had time to take a closer look) is that it might build things twice, but at least we mitigate this error

We still need to see what we can do on the gradle side to fix it, I’ll try to take a look on it in the following days.

@jehartzog as for the More than one file was found with OS independent path ... error, take a look at this stackoverflow post. This is not an issue with VisionCamera, but with how Android and Gradle works.

Add this to your build.gradle:

android {

    ...

    packagingOptions {
        pickFirst '**/*.so'
    }
}

I still wonder why the build has to be ran twice

I believe the build works if you run it twice, I just wonder why it doesn’t work the first time 🤨