react-native-vision-camera: ๐Ÿ”ง Android build error when enabling frame processor (V3 - RN 0.72.4)

How were you trying to build the app?

I tried to build my app on Android with npx react-native run-android and it fails.

Full build logs

info JS server already running.
info Installing the app...

> Configure project :react-native-firebase_app
:react-native-firebase_app package.json found at /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_app:firebase.bom using default value: 30.1.0
:react-native-firebase_app:play.play-services-auth using default value: 20.2.0
:react-native-firebase_app package.json found at /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_app:version set from package.json: 14.11.1 (14,11,1 - 14011001)
:react-native-firebase_app:android.compileSdk using custom value: 33
:react-native-firebase_app:android.targetSdk using custom value: 33
:react-native-firebase_app:android.minSdk using custom value: 26
:react-native-firebase_app:reactNativeAndroidDir /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native/android

> Configure project :react-native-firebase_crashlytics
:react-native-firebase_crashlytics package.json found at /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/@react-native-firebase/crashlytics/package.json
:react-native-firebase_app package.json found at /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_crashlytics:firebase.bom using default value: 30.1.0
:react-native-firebase_crashlytics package.json found at /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/@react-native-firebase/crashlytics/package.json
:react-native-firebase_crashlytics:version set from package.json: 14.11.1 (14,11,1 - 14011001)
:react-native-firebase_crashlytics:android.compileSdk using custom value: 33
:react-native-firebase_crashlytics:android.targetSdk using custom value: 33
:react-native-firebase_crashlytics:android.minSdk using custom value: 26
:react-native-firebase_crashlytics:reactNativeAndroidDir /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native/android

> Configure project :react-native-notifications
WARNING:DSL element 'dexOptions' is obsolete and should be removed.
It will be removed in version 8.0 of the Android Gradle plugin.
Using it has no effect, and the AndroidGradle plugin optimizes dexing automatically.

> Configure project :react-native-reanimated
No AAR for react-native-reanimated found. Attempting to build from source.
Android gradle plugin: 7.4.2
Gradle: 8.0.1
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :react-native-vision-camera
[VisionCamera] react-native-worklets-core found, Frame Processors enabled!

> Task :react-native-vision-camera:compileDebugKotlin
'compileDebugJavaWithJavac' task (current target is 11) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView+Events.kt: (7, 44): 'RCTEventEmitter' is deprecated. Deprecated in Java
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView+Events.kt: (13, 28): 'RCTEventEmitter' is deprecated. Deprecated in Java
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView+Events.kt: (13, 57): 'receiveEvent(Int, String!, WritableMap?): Unit' is deprecated. Deprecated in Java
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView+Events.kt: (31, 28): 'RCTEventEmitter' is deprecated. Deprecated in Java
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView+Events.kt: (31, 57): 'receiveEvent(Int, String!, WritableMap?): Unit' is deprecated. Deprecated in Java
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView+Events.kt: (37, 28): 'RCTEventEmitter' is deprecated. Deprecated in Java
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraView+Events.kt: (37, 57): 'receiveEvent(Int, String!, WritableMap?): Unit' is deprecated. Deprecated in Java
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/core/CameraSession.kt: (209, 9): Variable 'previewOutput' is never used
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/core/RecordingSession.kt: (49, 96): 'constructor MediaRecorder()' is deprecated. Deprecated in Java
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/extensions/CameraCharacteristics+getOutputSizes.kt: (46, 36): 'get(Int, Int): CamcorderProfile!' is deprecated. Deprecated in Java
w: /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/extensions/CameraDevice+createCaptureSession.kt: (92, 12): 'createCaptureSessionByOutputConfigurations((Mutable)List<OutputConfiguration!>!, CameraCaptureSession.StateCallback!, Handler?): Unit' is deprecated. Deprecated in Java

> Task :react-native-vision-camera:configureCMakeDebug[arm64-v8a] FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings
530 actionable tasks: 20 executed, 510 up-to-date

info ๐Ÿ’ก Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-vision-camera:configureCMakeDebug[arm64-v8a]'.
> [CXX1420] /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/CMakeLists.txt debug|arm64-v8a : Could not read '/Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/.cxx/Debug/491z6bu1/arm64-v8a/configure_fingerprint.bin': While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.

* 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

BUILD FAILED in 17s
error Failed to install the app.
info Run CLI with --verbose flag for more details.

โ•ญโ”€ ๏…น  ๏ผ ~/moveshelf/home-monitoring/HomeMonitoring  ๏Š– ๏„ฆ 144-body-figโ€ฆding-a-video !3 ๎‚ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€๎‚ฒ 1 โœ˜  29s ๏‰’  08:58:33 AM ๏€— โ”€โ•ฎ
โ•ฐโ”€ npx react-native run-android                                                                                                                                                  โ”€โ•ฏ
warn Package rn-fetch-blob contains invalid configuration: "dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info JS server already running.
info Installing the app...

> Configure project :react-native-firebase_app
:react-native-firebase_app package.json found at /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_app:firebase.bom using default value: 30.1.0
:react-native-firebase_app:play.play-services-auth using default value: 20.2.0
:react-native-firebase_app package.json found at /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_app:version set from package.json: 14.11.1 (14,11,1 - 14011001)
:react-native-firebase_app:android.compileSdk using custom value: 33
:react-native-firebase_app:android.targetSdk using custom value: 33
:react-native-firebase_app:android.minSdk using custom value: 26
:react-native-firebase_app:reactNativeAndroidDir /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native/android

> Configure project :react-native-firebase_crashlytics
:react-native-firebase_crashlytics package.json found at /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/@react-native-firebase/crashlytics/package.json
:react-native-firebase_app package.json found at /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_crashlytics:firebase.bom using default value: 30.1.0
:react-native-firebase_crashlytics package.json found at /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/@react-native-firebase/crashlytics/package.json
:react-native-firebase_crashlytics:version set from package.json: 14.11.1 (14,11,1 - 14011001)
:react-native-firebase_crashlytics:android.compileSdk using custom value: 33
:react-native-firebase_crashlytics:android.targetSdk using custom value: 33
:react-native-firebase_crashlytics:android.minSdk using custom value: 26
:react-native-firebase_crashlytics:reactNativeAndroidDir /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native/android

> Configure project :react-native-notifications
WARNING:DSL element 'dexOptions' is obsolete and should be removed.
It will be removed in version 8.0 of the Android Gradle plugin.
Using it has no effect, and the AndroidGradle plugin optimizes dexing automatically.

> Configure project :react-native-reanimated
No AAR for react-native-reanimated found. Attempting to build from source.
Android gradle plugin: 7.4.2
Gradle: 8.0.1
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :react-native-vision-camera
[VisionCamera] react-native-worklets-core found, Frame Processors enabled!

> Task :react-native-worklets-core:configureCMakeDebug[arm64-v8a]
C/C++: CMake Warning:
C/C++:   Manually-specified variables were not used by the project:
C/C++:     HERMES_ENABLE_DEBUGGER

> Task :react-native-worklets-core:configureCMakeDebug[armeabi-v7a]
C/C++: CMake Warning:
C/C++:   Manually-specified variables were not used by the project:
C/C++:     HERMES_ENABLE_DEBUGGER

> Task :react-native-worklets-core:configureCMakeDebug[x86]
C/C++: CMake Warning:
C/C++:   Manually-specified variables were not used by the project:
C/C++:     HERMES_ENABLE_DEBUGGER

> Task :react-native-worklets-core:configureCMakeDebug[x86_64]
C/C++: CMake Warning:
C/C++:   Manually-specified variables were not used by the project:
C/C++:     HERMES_ENABLE_DEBUGGER

> Task :react-native-vision-camera:configureCMakeDebug[arm64-v8a] FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings
530 actionable tasks: 32 executed, 498 up-to-date

info ๐Ÿ’ก Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-vision-camera:configureCMakeDebug[arm64-v8a]'.
> [CXX1420] /Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/CMakeLists.txt debug|arm64-v8a : Could not read '/Users/federicopregnolato/moveshelf/home-monitoring/HomeMonitoring/node_modules/react-native-vision-camera/android/.cxx/Debug/491z6bu1/arm64-v8a/configure_fingerprint.bin': While parsing a protocol message, the input ended unexpectedly in the middle of a field.  This could mean either that the input has been truncated or that an embedded message misreported its own length.

* 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

BUILD FAILED in 38s
error Failed to install the app.
info Run CLI with --verbose flag for more details.

Project dependencies

{
  "name": "homemonitoring",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "postinstall": "patch-package",
    "android": "npx react-native run-android",
    "ios": "npx react-native run-ios",
    "start": "npx react-native start",
    "sonarqube-server": "docker run -d -p 9000:9000 sonarqube-arm",
    "test": "jest --coverage --forceExit",
    "sonarqube-scanner": "sonar-scanner",
    "lint": "eslint --ext .js,.jsx,.ts,.tsx src",
    "build:android": "npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle && cd android && ./gradlew clean && ./gradlew assembleRelease && ./gradlew bundleRelease"
  },
  "dependencies": {
    "@apollo/client": "^3.5.10",
    "@babel/runtime": "^7.17.9",
    "@kingstinct/react-native-healthkit": "^4.2.0",
    "@react-native-async-storage/async-storage": "^1.18.2",
    "@react-native-firebase/app": "14.11.1",
    "@react-native-firebase/crashlytics": "14.11.1",
    "@react-native-masked-view/masked-view": "^0.2.9",
    "@react-native-picker/picker": "^2.4.10",
    "@react-native/metro-config": "^0.72.11",
    "@react-navigation/bottom-tabs": "^6.5.7",
    "@react-navigation/elements": "^1.3.18",
    "@react-navigation/native": "^6.0.8",
    "@react-navigation/native-stack": "^6.9.8",
    "@react-navigation/stack": "^6.2.0",
    "@sayem314/react-native-keep-awake": "^1.1.0",
    "@types/async-lock": "^1.1.5",
    "apollo-boost": "^0.4.9",
    "async-lock": "^1.3.1",
    "cross-fetch": "^3.1.5",
    "dayjs": "^1.11.2",
    "eslint-plugin-react": "^7.30.1",
    "ffmpeg-kit-react-native": "^5.1.0",
    "graphql": "^15.0.0",
    "install": "^0.13.0",
    "npm": "^8.10.0",
    "patch-package": "^8.0.0",
    "path": "^0.12.7",
    "react": "18.2.0",
    "react-native": "^0.72.4",
    "react-native-animated-stopwatch-timer": "^1.0.2",
    "react-native-camera": "^4.2.1",
    "react-native-csv": "^0.2.0",
    "react-native-device-info": "^9.0.2",
    "react-native-fs": "^2.18.0",
    "react-native-gesture-handler": "^2.12.0",
    "react-native-keychain": "^8.0.0",
    "react-native-mime-types": "^2.3.0",
    "react-native-notifications": "5.0.0",
    "react-native-performance": "^3.0.1",
    "react-native-permissions": "^3.3.1",
    "react-native-qrcode-scanner": "^1.5.5",
    "react-native-reanimated": "^3.3.0",
    "react-native-restart": "^0.0.24",
    "react-native-safe-area-context": "^4.5.3",
    "react-native-screens": "^3.21.0",
    "react-native-splash-screen": "^3.3.0",
    "react-native-svg": "^13.9.0",
    "react-native-udp": "^4.1.7",
    "react-native-ui-lib": "^6.15.0",
    "react-native-vector-icons": "^9.2.0",
    "react-native-vision-camera": "^3.0.0",
    "react-native-worklets-core": "^0.2.0",
    "react-navigation": "^4.4.4",
    "react-usestateref": "^1.0.8",
    "rn-fetch-blob": "^0.12.0",
    "text-encoding": "^0.7.0",
    "uint8arrays": "^3.0.0"
  },
  "devDependencies": {
    "@babel/preset-typescript": "^7.16.7",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/jest": "^27.5.1",
    "@types/lodash": "^4.14.182",
    "@types/react": "^18.0.24",
    "@types/react-native": "^0.68.15",
    "@types/react-native-vector-icons": "^6.4.13",
    "@types/react-test-renderer": "^18.0.0",
    "@typescript-eslint/eslint-plugin": "^5.17.0",
    "@typescript-eslint/parser": "^5.17.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^7.32.0",
    "jest-fetch-mock": "^3.0.3",
    "metro-react-native-babel-preset": "^0.76.5",
    "react-test-renderer": "18.2.0",
    "ts-jest": "^28.0.2",
    "ts-node": "^10.7.0",
    "typescript": "^4.8.4"
  },
  "resolutions": {
    "@types/react": "^17"
  },
  "engines": {
    "node": ">=16"
  }
}

Target platforms

Android

Operating system

MacOS

Can you build the VisionCamera Example app?

  • I can build the VisionCamera Example app.

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 1
  • Comments: 20 (4 by maintainers)

Most upvoted comments

In my experience, set(ENABLE_FRAME_PROCESSORS ON) actually disables the the frameprocessors instead of enabling them. This is why the build succeed as none of the worklets-core code is imported. The actual problem seemed to be that the CMake is not able to find the worklets-core library during the linking phase (at least for me the actual clang command did not include the worklets-core built library). This can be fixed by adding the direct path to the android/CMakeLists.txt file:

# Link everything together
target_link_libraries(
        ${PACKAGE_NAME}
        ${LOG_LIB}                          # <-- Logcat logger
        android                             # <-- Android JNI core
        ReactAndroid::jsi                   # <-- RN: JSI
        ReactAndroid::reactnativejni        # <-- RN: React Native JNI bindings
        ReactAndroid::folly_runtime         # <-- RN: For casting JSI <> Java objects
        fbjni::fbjni                        # <-- fbjni
 --->"${NODE_MODULES_DIR}/react-native-worklets-core/android/build/intermediates/cmake/debug/obj/${ANDROID_ABI}/librnworklets.so"
)

I think that there might be a cleaner way to do this but I found that this will work so left it at that. Be sure to remove the set(ENABLE_FRAME_PROCESSORS ON) if trying this.

After adding set(ENABLE_FRAME_PROCESSORS ON) to CMakeLists.txt Iโ€™m getting this error. without frameProcessor prop everything works fine, I think there is an issue with react-native-worklets-core.

"react-native-vision-camera": "3.0.0-rc.10",
"react-native-worklets-core": "^0.2.0",
"react-native": "0.72.0",
"react-native-reanimated": "^3.4.2",

babel.config.js

module.exports = {
	presets: ['module:metro-react-native-babel-preset'],
	plugins: [
		['react-native-reanimated/plugin'],
		['react-native-worklets-core/plugin'],
	],
};

2023-09-07 14 06 31

finally fixed with this line

"${NODE_MODULES_DIR}/react-native-worklets-core/android/build/intermediates/cmake/debug/obj/${ANDROID_ABI}/librnworklets.so"