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

🔧 AHardwareBuffer not available on API <26 #1898

Closed
3 of 5 tasks
igperez-ar opened this issue Oct 2, 2023 · 14 comments · Fixed by #1910
Closed
3 of 5 tasks

🔧 AHardwareBuffer not available on API <26 #1898

igperez-ar opened this issue Oct 2, 2023 · 14 comments · Fixed by #1910
Labels
🔧 build error Issue is related to building VisionCamera in your project

Comments

@igperez-ar
Copy link

How were you trying to build the app?

I tried to build my app with react-native-vision-camera using the yarn android command, and it failed.
I can´t also build the example project but for a different errors.

Full build logs

> Configure project :react-native-vision-camera
[VisionCamera] react-native-worklets-core not found, Frame Processors disabled!
Checking the license for package CMake 3.18.1 in /Users/user/Library/Android/sdk/licenses
License for package CMake 3.18.1 accepted.
Preparing "Install CMake 3.18.1 (revision: 3.18.1)".
"Install CMake 3.18.1 (revision: 3.18.1)" ready.
Installing CMake 3.18.1 in /Users/user/Library/Android/sdk/cmake/3.18.1
"Install CMake 3.18.1 (revision: 3.18.1)" complete.
"Install CMake 3.18.1 (revision: 3.18.1)" finished.

> Task :react-native-vision-camera:buildCMakeDebug[arm64-v8a]
C/C++: CMake Warning at /Users/user/Library/Android/sdk/ndk/23.1.7779620/build/cmake/android-legacy.toolchain.cmake:416 (message):
C/C++:   An old version of CMake is being used that cannot automatically detect
C/C++:   compiler attributes.  Compiler identification is being bypassed.  Some
C/C++:   values may be wrong or missing.  Update to CMake 3.19 or newer to use
C/C++:   CMake's built-in compiler identification.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/user/Library/Android/sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake:55 (include)
C/C++:   .cxx/Debug/5z1p2x5s/arm64-v8a/CMakeFiles/3.18.1-g262b901/CMakeSystem.cmake:6 (include)
C/C++:   CMakeLists.txt:1 (project)
C/C++: ninja: Entering directory `/Users/user/app/node_modules/react-native-vision-camera/android/.cxx/Debug/5z1p2x5s/arm64-v8a'
C/C++: ../../../../src/main/cpp/frameprocessor/java-bindings/JFrame.cpp:65:10: error: 'AHardwareBuffer_fromHardwareBuffer' is unavailable: introduced in Android 26
C/C++: /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer_jni.h:48:18: note: 'AHardwareBuffer_fromHardwareBuffer' has been explicitly marked unavailable here
C/C++: ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:91:7: error: 'AHardwareBuffer_describe' is unavailable: introduced in Android 26
C/C++: /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:387:6: note: 'AHardwareBuffer_describe' has been explicitly marked unavailable here
C/C++: ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:112:7: error: 'AHardwareBuffer_lock' is unavailable: introduced in Android 26
C/C++: /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:442:5: note: 'AHardwareBuffer_lock' has been explicitly marked unavailable here
C/C++: ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:119:7: error: 'AHardwareBuffer_unlock' is unavailable: introduced in Android 26
C/C++: /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:464:5: note: 'AHardwareBuffer_unlock' has been explicitly marked unavailable here
C/C++: ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:120:7: error: 'AHardwareBuffer_release' is unavailable: introduced in Android 26
C/C++: /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:379:6: note: 'AHardwareBuffer_release' has been explicitly marked unavailable here

> Task :react-native-vision-camera:buildCMakeDebug[arm64-v8a] FAILED
C/C++: ninja: Entering directory `/Users/user/app/node_modules/react-native-vision-camera/android/.cxx/Debug/5z1p2x5s/arm64-v8a'
C/C++: ../../../../src/main/cpp/frameprocessor/java-bindings/JFrame.cpp:65:10: error: 'AHardwareBuffer_fromHardwareBuffer' is unavailable: introduced in Android 26
C/C++: /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer_jni.h:48:18: note: 'AHardwareBuffer_fromHardwareBuffer' has been explicitly marked unavailable here
C/C++: ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:91:7: error: 'AHardwareBuffer_describe' is unavailable: introduced in Android 26
C/C++: /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:387:6: note: 'AHardwareBuffer_describe' has been explicitly marked unavailable here
C/C++: ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:112:7: error: 'AHardwareBuffer_lock' is unavailable: introduced in Android 26
C/C++: /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:442:5: note: 'AHardwareBuffer_lock' has been explicitly marked unavailable here
C/C++: ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:119:7: error: 'AHardwareBuffer_unlock' is unavailable: introduced in Android 26
C/C++: /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:464:5: note: 'AHardwareBuffer_unlock' has been explicitly marked unavailable here
C/C++: ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:120:7: error: 'AHardwareBuffer_release' is unavailable: introduced in Android 26
C/C++: /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:379:6: note: 'AHardwareBuffer_release' has been explicitly marked unavailable here

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.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/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
691 actionable tasks: 136 executed, 555 up-to-date

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-vision-camera:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/Users/user/app/node_modules/react-native-vision-camera/android/.cxx/Debug/5z1p2x5s/arm64-v8a'
  [1/5] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp.o
  FAILED: CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp.o
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android23 --gcc-toolchain=/Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -DVISION_CAMERA_ENABLE_FRAME_PROCESSORS=false -DVisionCamera_EXPORTS -I../../../../../cpp -I../../../../src/main/cpp -I../../../../src/main/cpp/frameprocessor -I../../../../src/main/cpp/frameprocessor/java-bindings -I/Users/user/app/node_modules/react-native/ReactCommon -I/Users/user/app/node_modules/react-native/ReactCommon/callinvoker -I/Users/user/app/node_modules/react-native/ReactAndroid/src/main/jni/react/turbomodule -isystem /Users/user/.gradle/caches/transforms-3/8bcf80ee2a1bfa604895db953412a7ec/transformed/jetified-react-android-0.71.1-debug/prefab/modules/jsi/include -isystem /Users/user/.gradle/caches/transforms-3/8bcf80ee2a1bfa604895db953412a7ec/transformed/jetified-react-android-0.71.1-debug/prefab/modules/reactnativejni/include -isystem /Users/user/.gradle/caches/transforms-3/2e68e23f8328304be19dadb03640c2bb/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all -fno-limit-debug-info  -fPIC -std=gnu++17 -MD -MT CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp.o -MF CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp.o.d -o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp.o -c ../../../../src/main/cpp/frameprocessor/java-bindings/JFrame.cpp
  ../../../../src/main/cpp/frameprocessor/java-bindings/JFrame.cpp:65:10: error: 'AHardwareBuffer_fromHardwareBuffer' is unavailable: introduced in Android 26
    return AHardwareBuffer_fromHardwareBuffer(jni::Environment::current(), hardwareBuffer.get());
           ^
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer_jni.h:48:18: note: 'AHardwareBuffer_fromHardwareBuffer' has been explicitly marked unavailable here
  AHardwareBuffer* AHardwareBuffer_fromHardwareBuffer(JNIEnv* env,
                   ^
  1 error generated.
  [2/5] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/FrameHostObject.cpp.o
  FAILED: CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/FrameHostObject.cpp.o
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android23 --gcc-toolchain=/Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -DVISION_CAMERA_ENABLE_FRAME_PROCESSORS=false -DVisionCamera_EXPORTS -I../../../../../cpp -I../../../../src/main/cpp -I../../../../src/main/cpp/frameprocessor -I../../../../src/main/cpp/frameprocessor/java-bindings -I/Users/user/app/node_modules/react-native/ReactCommon -I/Users/user/app/node_modules/react-native/ReactCommon/callinvoker -I/Users/user/app/node_modules/react-native/ReactAndroid/src/main/jni/react/turbomodule -isystem /Users/user/.gradle/caches/transforms-3/8bcf80ee2a1bfa604895db953412a7ec/transformed/jetified-react-android-0.71.1-debug/prefab/modules/jsi/include -isystem /Users/user/.gradle/caches/transforms-3/8bcf80ee2a1bfa604895db953412a7ec/transformed/jetified-react-android-0.71.1-debug/prefab/modules/reactnativejni/include -isystem /Users/user/.gradle/caches/transforms-3/2e68e23f8328304be19dadb03640c2bb/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all -fno-limit-debug-info  -fPIC -std=gnu++17 -MD -MT CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/FrameHostObject.cpp.o -MF CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/FrameHostObject.cpp.o.d -o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/FrameHostObject.cpp.o -c ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp
  ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:91:7: error: 'AHardwareBuffer_describe' is unavailable: introduced in Android 26
        AHardwareBuffer_describe(hardwareBuffer, &bufferDescription);
        ^
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:387:6: note: 'AHardwareBuffer_describe' has been explicitly marked unavailable here
  void AHardwareBuffer_describe(const AHardwareBuffer* _Nonnull buffer,
       ^
  ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:112:7: error: 'AHardwareBuffer_lock' is unavailable: introduced in Android 26
        AHardwareBuffer_lock(hardwareBuffer, AHARDWAREBUFFER_USAGE_CPU_READ_MASK, -1, nullptr, &buffer);
        ^
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:442:5: note: 'AHardwareBuffer_lock' has been explicitly marked unavailable here
  int AHardwareBuffer_lock(AHardwareBuffer* _Nonnull buffer, uint64_t usage, int32_t fence,
      ^
  ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:119:7: error: 'AHardwareBuffer_unlock' is unavailable: introduced in Android 26
        AHardwareBuffer_unlock(hardwareBuffer, nullptr);
        ^
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:464:5: note: 'AHardwareBuffer_unlock' has been explicitly marked unavailable here
  int AHardwareBuffer_unlock(AHardwareBuffer* _Nonnull buffer, int32_t* _Nullable fence)
      ^
  ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:120:7: error: 'AHardwareBuffer_release' is unavailable: introduced in Android 26
        AHardwareBuffer_release(hardwareBuffer);
        ^
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:379:6: note: 'AHardwareBuffer_release' has been explicitly marked unavailable here
  void AHardwareBuffer_release(AHardwareBuffer* _Nonnull buffer) __INTRODUCED_IN(26);
       ^
  4 errors generated.
  [3/5] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.cpp.o
  [4/5] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JVisionCameraScheduler.cpp.o
  ninja: build stopped: subcommand failed.

  C++ build system [build] failed while executing:
      /Users/user/Library/Android/sdk/cmake/3.18.1/bin/ninja \
        -C \
        /Users/user/app/node_modules/react-native-vision-camera/android/.cxx/Debug/5z1p2x5s/arm64-v8a \
        VisionCamera
    from /Users/user/app/node_modules/react-native-vision-camera/android

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* 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 1m 15s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-vision-camera:buildCMakeDebug[arm64-v8a]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/Users/user/app/node_modules/react-native-vision-camera/android/.cxx/Debug/5z1p2x5s/arm64-v8a'
  [1/5] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp.o
  FAILED: CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp.o
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android23 --gcc-toolchain=/Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -DVISION_CAMERA_ENABLE_FRAME_PROCESSORS=false -DVisionCamera_EXPORTS -I../../../../../cpp -I../../../../src/main/cpp -I../../../../src/main/cpp/frameprocessor -I../../../../src/main/cpp/frameprocessor/java-bindings -I/Users/user/app/node_modules/react-native/ReactCommon -I/Users/user/app/node_modules/react-native/ReactCommon/callinvoker -I/Users/user/app/node_modules/react-native/ReactAndroid/src/main/jni/react/turbomodule -isystem /Users/user/.gradle/caches/transforms-3/8bcf80ee2a1bfa604895db953412a7ec/transformed/jetified-react-android-0.71.1-debug/prefab/modules/jsi/include -isystem /Users/user/.gradle/caches/transforms-3/8bcf80ee2a1bfa604895db953412a7ec/transformed/jetified-react-android-0.71.1-debug/prefab/modules/reactnativejni/include -isystem /Users/user/.gradle/caches/transforms-3/2e68e23f8328304be19dadb03640c2bb/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all -fno-limit-debug-info  -fPIC -std=gnu++17 -MD -MT CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp.o -MF CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp.o.d -o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp.o -c ../../../../src/main/cpp/frameprocessor/java-bindings/JFrame.cpp
  ../../../../src/main/cpp/frameprocessor/java-bindings/JFrame.cpp:65:10: error: 'AHardwareBuffer_fromHardwareBuffer' is unavailable: introduced in Android 26
    return AHardwareBuffer_fromHardwareBuffer(jni::Environment::current(), hardwareBuffer.get());
           ^
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer_jni.h:48:18: note: 'AHardwareBuffer_fromHardwareBuffer' has been explicitly marked unavailable here
  AHardwareBuffer* AHardwareBuffer_fromHardwareBuffer(JNIEnv* env,
                   ^
  1 error generated.
  [2/5] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/FrameHostObject.cpp.o
  FAILED: CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/FrameHostObject.cpp.o
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android23 --gcc-toolchain=/Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -DVISION_CAMERA_ENABLE_FRAME_PROCESSORS=false -DVisionCamera_EXPORTS -I../../../../../cpp -I../../../../src/main/cpp -I../../../../src/main/cpp/frameprocessor -I../../../../src/main/cpp/frameprocessor/java-bindings -I/Users/user/app/node_modules/react-native/ReactCommon -I/Users/user/app/node_modules/react-native/ReactCommon/callinvoker -I/Users/user/app/node_modules/react-native/ReactAndroid/src/main/jni/react/turbomodule -isystem /Users/user/.gradle/caches/transforms-3/8bcf80ee2a1bfa604895db953412a7ec/transformed/jetified-react-android-0.71.1-debug/prefab/modules/jsi/include -isystem /Users/user/.gradle/caches/transforms-3/8bcf80ee2a1bfa604895db953412a7ec/transformed/jetified-react-android-0.71.1-debug/prefab/modules/reactnativejni/include -isystem /Users/user/.gradle/caches/transforms-3/2e68e23f8328304be19dadb03640c2bb/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all -fno-limit-debug-info  -fPIC -std=gnu++17 -MD -MT CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/FrameHostObject.cpp.o -MF CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/FrameHostObject.cpp.o.d -o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/FrameHostObject.cpp.o -c ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp
  ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:91:7: error: 'AHardwareBuffer_describe' is unavailable: introduced in Android 26
        AHardwareBuffer_describe(hardwareBuffer, &bufferDescription);
        ^
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:387:6: note: 'AHardwareBuffer_describe' has been explicitly marked unavailable here
  void AHardwareBuffer_describe(const AHardwareBuffer* _Nonnull buffer,
       ^
  ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:112:7: error: 'AHardwareBuffer_lock' is unavailable: introduced in Android 26
        AHardwareBuffer_lock(hardwareBuffer, AHARDWAREBUFFER_USAGE_CPU_READ_MASK, -1, nullptr, &buffer);
        ^
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:442:5: note: 'AHardwareBuffer_lock' has been explicitly marked unavailable here
  int AHardwareBuffer_lock(AHardwareBuffer* _Nonnull buffer, uint64_t usage, int32_t fence,
      ^
  ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:119:7: error: 'AHardwareBuffer_unlock' is unavailable: introduced in Android 26
        AHardwareBuffer_unlock(hardwareBuffer, nullptr);
        ^
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:464:5: note: 'AHardwareBuffer_unlock' has been explicitly marked unavailable here
  int AHardwareBuffer_unlock(AHardwareBuffer* _Nonnull buffer, int32_t* _Nullable fence)
      ^
  ../../../../src/main/cpp/frameprocessor/FrameHostObject.cpp:120:7: error: 'AHardwareBuffer_release' is unavailable: introduced in Android 26
        AHardwareBuffer_release(hardwareBuffer);
        ^
  /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/android/hardware_buffer.h:379:6: note: 'AHardwareBuffer_release' has been explicitly marked unavailable here
  void AHardwareBuffer_release(AHardwareBuffer* _Nonnull buffer) __INTRODUCED_IN(26);
       ^
  4 errors generated.
  [3/5] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.cpp.o
  [4/5] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessor/java-bindings/JVisionCameraScheduler.cpp.o
  ninja: build stopped: subcommand failed.

  C++ build system [build] failed while executing:
      /Users/user/Library/Android/sdk/cmake/3.18.1/bin/ninja \
        -C \
        /Users/user/app/node_modules/react-native-vision-camera/android/.cxx/Debug/5z1p2x5s/arm64-v8a \
        VisionCamera
    from /Users/user/app/node_modules/react-native-vision-camera/android

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* 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 1m 15s

    at makeError (/Users/user/app/node_modules/execa/index.js:174:9)
    at /Users/user/app/node_modules/execa/index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (/Users/user/app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:82:7)
    at async Command.handleAction (/Users/user/app/node_modules/@react-native-community/cli/build/index.js:108:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.

Project dependencies

"dependencies": {
    "@aws-amplify/pushnotification": "4.3.43",
    "@babel/plugin-proposal-private-methods": "7.18.6",
    "@react-native-async-storage/async-storage": "1.18.1",
    "@react-native-clipboard/clipboard": "1.11.2",
    "@react-native-community/geolocation": "3.0.6",
    "@react-native-community/image-editor": "2.3.0",
    "@react-native-community/netinfo": "9.3.10",
    "@react-native-community/push-notification-ios": "1.11.0",
    "@react-native-firebase/analytics": "17.4.3",
    "@react-native-firebase/app": "17.4.3",
    "@react-native-firebase/crashlytics": "17.4.3",
    "@react-native-firebase/remote-config": "17.4.3",
    "@react-native-masked-view/masked-view": "0.2.9",
    "@react-navigation/bottom-tabs": "6.5.7",
    "@react-navigation/native": "6.1.6",
    "@react-navigation/native-stack": "6.9.12",
    "@reduxjs/toolkit": "1.9.5",
    "@shopify/restyle": "2.4.2",
    "@types/react-native-snap-carousel": "3.8.5",
    "@types/react-redux": "7.1.25",
    "@typescript-eslint/eslint-plugin": "5.59.7",
    "amazon-cognito-identity-js": "5.2.14",
    "aws-amplify": "5.0.17",
    "axios": "0.24.0",
    "formik": "2.2.9",
    "i18next": "21.10.0",
    "lottie-react-native": "5.1.5",
    "moment": "2.29.4",
    "moment-timezone": "0.5.43",
    "native-base": "3.4.28",
    "ramda": "0.27.2",
    "react": "18.2.0",
    "react-countdown-hook": "1.1.1",
    "react-error-boundary": "3.1.4",
    "react-hook-form": "7.43.9",
    "react-native": "0.71.1",
    "react-native-aes-crypto": "2.1.1",
    "react-native-biometrics": "3.0.1",
    "react-native-blob-util": "0.18.2",
    "react-native-compressor": "1.6.1",
    "react-native-config": "1.5.1",
    "react-native-date-picker": "4.2.5",
    "react-native-device-info": "8.7.1",
    "react-native-exception-handler": "2.10.10",
    "react-native-extended-stylesheet": "0.12.0",
    "react-native-fs": "2.20.0",
    "react-native-gesture-handler": "2.10.1",
    "react-native-keychain": "8.1.1",
    "react-native-linear-gradient": "2.6.2",
    "react-native-localize": "2.2.6",
    "react-native-modalize": "2.1.1",
    "react-native-pdf": "6.6.2",
    "react-native-permissions": "3.8.0",
    "react-native-portalize": "1.0.7",
    "react-native-push-notification": "8.1.1",
    "react-native-reanimated": "2.17.0",
    "react-native-responsive-fontsize": "0.5.1",
    "react-native-safe-area-context": "4.5.3",
    "react-native-screens": "3.20.0",
    "react-native-share": "8.2.2",
    "react-native-skeleton-placeholder": "5.2.4",
    "react-native-snap-carousel": "4.0.0-beta.6",
    "react-native-svg": "12.4.0",
    "react-native-toast-message": "2.1.6",
    "react-native-track-player": "3.2.0",
    "react-native-uuid": "2.0.1",
    "react-native-vector-icons": "9.2.0",
    "react-native-vision-camera": "3.2.2",
    "react-native-walkthrough-tooltip": "1.5.0",
    "react-native-webview": "11.26.1",
    "react-redux": "7.2.9",
    "redux-persist": "6.0.0",
    "redux-saga": "1.2.3",
    "usehooks-ts": "2.9.1",
    "ws": "5.2.3",
    "yup": "0.32.11"
  }

VisionCamera Version

3.2.2

Target platforms

Android

Operating system

MacOS

Can you build the VisionCamera Example app?

No, I cannot build the Example app either

Additional information

@igperez-ar igperez-ar added the 🔧 build error Issue is related to building VisionCamera in your project label Oct 2, 2023
@fobos531
Copy link
Contributor

fobos531 commented Oct 2, 2023

Hey @igperez-ar,

based on your build logs, it seems that your minSdkVersion is set to a value lower than 26. Recent versions of Vision Camera require at least API 26, so that might be the cause of your issue. I'm building my app with minSdkVersion set to 26 and it works just fine.

@mrousavy
Copy link
Owner

mrousavy commented Oct 2, 2023

Exactly what @fobos531 said (thanks!) 👍

@mrousavy mrousavy closed this as completed Oct 2, 2023
@mrousavy mrousavy changed the title 🔧 🔧 AHardwareBuffer not available on API <26 Oct 2, 2023
@hamdij0maa
Copy link

same problem

@mrousavy
Copy link
Owner

mrousavy commented Oct 2, 2023

wdym same problem? the comment above literally tells you the solution.

@hamdij0maa
Copy link

i'll recheck maybe something else causing the build failure :D thank you

@pepperav
Copy link

pepperav commented Oct 3, 2023

Hey @igperez-ar,

based on your build logs, it seems that your minSdkVersion is set to a value lower than 26. Recent versions of Vision Camera require at least API 26, so that might be the cause of your issue. I'm building my app with minSdkVersion set to 26 and it works just fine.

what is exactly the file and the line to edit?

I've tried android/build.gradle line 6 but without any success

image

I got always same error:
image

@mrousavy
Copy link
Owner

mrousavy commented Oct 3, 2023

Did you check in both app/build.gradle and build.gradle?

@pepperav
Copy link

pepperav commented Oct 3, 2023

Yes I did

build.gradle
image

app/build.gradle
image

Any suggestion? What can I try more?
Tnx

@mrousavy
Copy link
Owner

mrousavy commented Oct 3, 2023

just set it to 26 directly, I don#t know otherwise - maybe you have a caching issue clear yo cache

@pepperav
Copy link

pepperav commented Oct 3, 2023

Nothing, I did a lot of tries but I get always same error

what I did:

  • delete all folders (android, ios, node_modules, .expo) before every build
  • delete package-lock.json
  • added 26 directly at line 6 col 25 of /android/build.gradle
  • updated Android Studio with Android Studio Giraffe | 2022.3.1 Patch 2
  • applied all of this guide lines here

image

No idea left 😅

@hamdij0maa
Copy link

just upgrade to the last version ,
than : npx clean-rn
yarn install
./gradlew clean
yarn android

@mrousavy
Copy link
Owner

mrousavy commented Oct 3, 2023

I actually made a PR that makes it possible to use VisionCamera on minSdkVersion 25 or lower, see this: #1910

Hope that works :)

@pepperav
Copy link

pepperav commented Oct 3, 2023

I actually made a PR that makes it possible to use VisionCamera on minSdkVersion 25 or lower, see this: #1910

Hope that works :)

Tnx man! I appreciate it.

So what is the procedure now for this pr? I'm pretty new with this stuff

@haianh230797
Copy link

haianh230797 commented Oct 25, 2023

I actually made a PR that makes it possible to use VisionCamera on minSdkVersion 25 or lower, see this: #1910

Hope that works :)

Many thanks, it's really work <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 build error Issue is related to building VisionCamera in your project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants