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

Android Build Failed in MacOS #212

Open
Neelshah768 opened this issue Sep 9, 2024 · 9 comments
Open

Android Build Failed in MacOS #212

Neelshah768 opened this issue Sep 9, 2024 · 9 comments

Comments

@Neelshah768
Copy link

SDK Version Mismatch in React Native Project

Description

After installing the package and attempting to run yarn dev, I'm encountering an error related to SDK version mismatch. The error message suggests a discrepancy between the user's minSdkVersion and the library's build version.

Error Message


> Task :react-native-worklets-core:configureCMakeDebug[arm64-v8a] FAILED
C/C++: /Users/promethean/testProject/testProject/node_modules/react-native-worklets-core/android/CMakeLists.txt debug|arm64-v8a : com.google.prefab.api.NoMatchingLibraryException: No compatible library found for //ReactAndroid/fabricjni. Rejected the following libraries:

> Task :app:compileDebugKotlin
48 actionable tasks: 12 executed, 36 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx 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 

Note: /Users/promethean/testProject/testProject/node_modules/react-native-worklets-core/android/src/main/java/com/worklets/WorkletsPackage.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-worklets-core:configureCMakeDebug[arm64-v8a]'.
> [CXX1214] /Users/promethean/testProject/testProject/node_modules/react-native-worklets-core/android/CMakeLists.txt debug|arm64-v8a : User has minSdkVersion 22 but library was built for 23 [//ReactAndroid/fabricjni]

Project Configuration

My build.gradle file includes the following configuration:

ext {
    buildToolsVersion = "34.0.0"
    minSdkVersion = 26
    compileSdkVersion = 34
    targetSdkVersion = 34
    ndkVersion = "26.1.10909125"
    kotlinVersion = "1.9.22"
}

Expected Behavior

Given that my minSdkVersion is set to 26, which is higher than both the error-mentioned versions (22 and 23), I expected the project to build without SDK version conflicts.

Actual Behavior

The build process fails, reporting a mismatch between the user's SDK version (reportedly 22) and the library's build version (23), despite the build.gradle file specifying a minSdkVersion of 26.

Environment

 "react": "18.2.0",
"react-native": "0.74.5",
"react-native-worklets-core": "^1.3.3"
"node-version": 20.12.2

Steps to Reproduce

  1. Install the package (react-native-worklets-core)
  2. Run yarn dev
@dkumar-carfax
Copy link

Having same issue

1 similar comment
@TejasSoneri
Copy link

Having same issue

@Virajmakwana
Copy link

Virajmakwana commented Sep 10, 2024

+1

@dkumar-carfax
Copy link

dkumar-carfax commented Sep 10, 2024

If anyone is looking for a workaround, Downgrading react-native-vision-camera to version 4.5.2 worked for me.

@christophemenager
Copy link

Many thanks @dkumar-carfax ! I lost my day on this issue, but indeed 4.5.3 introduces this issue, rolling back to 4.5.2 solves the issue for me too.

@Neelshah768
Copy link
Author

@dkumar-carfax and @christophemenager I am already using the same version("react-native-vision-camera": "^4.5.2") but not working in my project.

  • Error *
    /Users/promethean/LivCast/livcast-app/node_modules/react-native-video/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details. FAILURE: Build failed with an exception. * What went wrong:
    Execution failed for task ':react-native-worklets-core:configureCMakeDebug[arm64-v8a]'.

[CXX1214] /Users/promethean/LivCast/livcast-app/node_modules/react-native-worklets-core/android/CMakeLists.txt debug|arm64-v8a : User has minSdkVersion 22 but library was built for 23 [//ReactAndroid/fabricjni]

@YashM20
Copy link

YashM20 commented Sep 11, 2024

For new architecture,

I tried using "react-native-worklets-core": "2.0.0-beta.3", its working but its not compatible with "react-native-vision-camera": "^4.5.2"

so, I changed it to 2.0.0-beta.1, its working ⚒

. Update package.json:

{
  "dependencies": {
    "react-native-worklets-core": "2.0.0-beta.1",
    "react-native-vision-camera": "^4.5.2"
  }
}
  1. Clean and rebuild:

    rm -rf node_modules
    rm yarn.lock # or package-lock.json if using npm
    yarn install # or npm install
    yarn dev # or npm run dev

Note

This combination works with the new architecture and resolves conflicts between react-native-worklets-core and react-native-vision-camera.

@tastydev
Copy link

tastydev commented Oct 18, 2024

Hey i am encountering similiar build issues on Android using frameProcessors.

What i see is that this configuration definitely builds and works sometimes! And then stops building as soon as i do

cd android && ./gradlew clean && cd .. After the gradlew clean it breaks on rebuilding/reinstallation

When the issue occurs:

  • deleting caches won't work (yarn, metro, rn, gradle, deleting .gradle etc.)
  • It starts working as soon as i install different package versions and rolling back to the one written below

Same behaviour on available beta versions.

ENV: m1 macOS: 14.5 (23F79)
{
  "dependencies": {
    "react-native": "0.74.5",
    "react-native-worklets-core": "1.3.3",
   "react-native-vision-camera": "4.5.3", // same issue with 4.5.x
  }
}

error trace if it occurs:

{\rtf1\ansi\ansicpg1252\cocoartf2761
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0

\f0\fs24 \cf0 Execution failed for task ':react-native-vision-camera:buildCMakeDebug[arm64-v8a]'.\
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/Users/user/Applications/exampleApp/app/node_modules/react-native-vision-camera/android/.cxx/Debug/19567bw1/arm64-v8a' [1/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JFrameProcessorPlugin.cpp.o [2/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/MutableJByteBuffer.cpp.o [3/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JFrame.cpp.o [4/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCamera.cpp.o [5/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/FrameProcessorPluginHostObject.cpp.o [6/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraScheduler.cpp.o [7/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JSharedArray.cpp.o [8/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JFrameProcessor.cpp.o [9/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/FrameHostObject.cpp.o [10/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/VisionCameraProxy.cpp.o [11/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/JSIJNIConversion.cpp.o [12/13] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o [13/13] Linking CXX shared library ../../../../build/intermediates/cxx/Debug/19567bw1/obj/arm64-v8a/libVisionCamera.so FAILED: ../../../../build/intermediates/cxx/Debug/19567bw1/obj/arm64-v8a/libVisionCamera.so : && /Users/user/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android23 --sysroot=/Users/user/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -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 -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libVisionCamera.so -o ../../../../build/intermediates/cxx/Debug/19567bw1/obj/arm64-v8a/libVisionCamera.so CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCamera.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/MutableJByteBuffer.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/FrameHostObject.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/FrameProcessorPluginHostObject.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/JSIJNIConversion.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/VisionCameraProxy.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JSharedArray.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JFrame.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JFrameProcessor.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JFrameProcessorPlugin.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraScheduler.cpp.o /Users/user/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/23/liblog.so -landroid /Users/user/.gradle/caches/transforms-4/42b1b200baf9fbb1e199a5ff8734cd20/transformed/jetified-react-android-0.74.5-debug/prefab/modules/jsi/libs/android.arm64-v8a/libjsi.so /Users/user/.gradle/caches/transforms-4/42b1b200baf9fbb1e199a5ff8734cd20/transformed/jetified-react-android-0.74.5-debug/prefab/modules/reactnativejni/libs/android.arm64-v8a/libreactnativejni.so /Users/user/.gradle/caches/transforms-4/3bb9a63bb87e3d3145432ff6e51ac3d9/transformed/jetified-fbjni-0.6.0/prefab/modules/fbjni/libs/android.arm64-v8a/libfbjni.so -latomic -lm && : ld.lld: error: undefined symbol: RNWorklet::JsiWorkletContext::initialize(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>> const&, facebook::jsi::Runtime*, std::__ndk1::function<void (std::__ndk1::function<void ()>&&)>, std::__ndk1::function<void (std::__ndk1::function<void ()>&&)>) >>> referenced by JVisionCameraProxy.cpp:45 (/Users/user/Applications/exampleApp/app/node_modules/react-native-vision-camera/android/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp:45) >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o:(vision::JVisionCameraProxy::JVisionCameraProxy(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<vision::JVisionCameraProxy, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*> const&, facebook::jsi::Runtime*, std::__ndk1::shared_ptr<facebook::react::CallInvoker> const&, facebook::jni::basic_strong_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<vision::JVisionCameraScheduler, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*, facebook::jni::GlobalReferenceAllocator> const&)) ld.lld: error: undefined symbol: RNWorklet::JsiWorkletContext::JsiWorkletContext(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>> const&) >>> referenced by shared_ptr.h:279 (/Users/user/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/__memory/shared_ptr.h:279) >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o:(std::__ndk1::__shared_ptr_emplace<RNWorklet::JsiWorkletContext, std::__ndk1::allocator<RNWorklet::JsiWorkletContext>>::__shared_ptr_emplace[abi:v170000]<char const (&) [13]>(std::__ndk1::allocator<RNWorklet::JsiWorkletContext>, char const (&) [13])) ld.lld: error: undefined symbol: RNWorklet::JsiWorkletContext::getWorkletRuntime() >>> referenced by JVisionCameraProxy.h:42 (/Users/user/Applications/exampleApp/app/node_modules/react-native-vision-camera/android/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.h:42) >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JSharedArray.cpp.o:(vision::JSharedArray::JSharedArray(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<vision::JSharedArray, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*> const&, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<vision::JVisionCameraProxy, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*> const&, facebook::jni::alias_ref<facebook::jni::JByteBuffer>)) >>> referenced by JFrameProcessor.cpp:37 (/Users/user/Applications/exampleApp/app/node_modules/react-native-vision-camera/android/src/main/cpp/frameprocessors/java-bindings/JFrameProcessor.cpp:37) >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JFrameProcessor.cpp.o:(vision::JFrameProcessor::callWithFrameHostObject(std::__ndk1::shared_ptr<vision::FrameHostObject> const&) const) ld.lld: error: undefined symbol: RNWorklet::JsiHostObject::JsiHostObject() >>> referenced by WKTJsiWorklet.h:82 (/Users/user/Applications/exampleApp/app/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorklet.h:82) >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o:(RNWorklet::JsiWorklet::JsiWorklet(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<facebook::jsi::Function>)) ld.lld: error: undefined symbol: RNWorklet::JsiHostObject::~JsiHostObject() >>> referenced by WKTJsiWorklet.h:84 (/Users/user/Applications/exampleApp/app/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorklet.h:84) >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o:(RNWorklet::JsiWorklet::JsiWorklet(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<facebook::jsi::Function>)) >>> referenced by WKTJsiWorklet.h:75 (/Users/user/Applications/exampleApp/app/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorklet.h:75) >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o:(RNWorklet::JsiWorklet::~JsiWorklet()) ld.lld: error: undefined symbol: RNWorklet::RuntimeLifecycleMonitor::addListener(facebook::jsi::Runtime&, RNWorklet::RuntimeLifecycleListener*) >>> referenced by WKTRuntimeAwareCache.h:46 (/Users/user/Applications/exampleApp/app/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTRuntimeAwareCache.h:46) >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::RuntimeAwareCache<std::__ndk1::shared_ptr<facebook::jsi::Function>>::get(facebook::jsi::Runtime&)) ld.lld: error: undefined symbol: RNWorklet::JsiWrapper::wrap(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWrapper*, bool) >>> referenced by WKTJsiWrapper.h:72 (/Users/user/Applications/exampleApp/app/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWrapper.h:72) >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o:(RNWorklet::JsiWorklet::createWorklet(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<facebook::jsi::Function>)) ld.lld: error: undefined symbol: RNWorklet::RuntimeLifecycleMonitor::removeListener(facebook::jsi::Runtime&, RNWorklet::RuntimeLifecycleListener*) >>> referenced by WKTRuntimeAwareCache.h:37 (/Users/user/Applications/exampleApp/app/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTRuntimeAwareCache.h:37) >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::RuntimeAwareCache<std::__ndk1::shared_ptr<facebook::jsi::Function>>::~RuntimeAwareCache()) ld.lld: error: undefined symbol: RNWorklet::JsiHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&) >>> referenced by JVisionCameraProxy.cpp >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o:(vtable for RNWorklet::JsiWorklet) ld.lld: error: undefined symbol: RNWorklet::JsiHostObject::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&) >>> referenced by JVisionCameraProxy.cpp >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o:(vtable for RNWorklet::JsiWorklet) ld.lld: error: undefined symbol: RNWorklet::JsiHostObject::getPropertyNames(facebook::jsi::Runtime&) >>> referenced by JVisionCameraProxy.cpp >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o:(vtable for RNWorklet::JsiWorklet) ld.lld: error: undefined symbol: typeinfo for RNWorklet::JsiHostObject >>> referenced by JVisionCameraProxy.cpp >>> CMakeFiles/VisionCamera.dir/src/main/cpp/frameprocessors/java-bindings/JVisionCameraProxy.cpp.o:(typeinfo for RNWorklet::JsiWorklet) clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.}

@mrousavy Sry for pinging but do you know which versions are definitely working together in your dev environment? Idk what it is but something is fucked up with Android builds related to react-native-vision-camera and enabled frameProcessors while using react-native-worklets-core

UPDATE:
The setup below is working stable now, as i found the right caches to delete as i found this issue mrousavy/react-native-vision-camera#2552

{
  "dependencies": {
    "react-native": "0.74.5",
    "react-native-worklets-core": "1.3.3",
   "react-native-vision-camera": "4.5.3",
  }
}

The issue happens if you use build -> clean inside Android Studio which fallbacks to ./gradlew clean what we also have used inside our clean script for the android part of the app.

so i changed "clean-android": "cd android && ./gradlew clean && cd ..", to "clean-android": "cd android && rm -rf .gradle .idea build app/.idea app/build && cd ..", inside our package.json scripts, and it always builds successfully now if people are cleaning their project structure for other reasons via our yarn scripts.

Of course this is just a workaround fix to be productive again and doesn't resolve the real issue inside the building setup of rn-vision-camera combined with rn-worklets-core but i hope some people can resolve their issues for now and can continue working.

Cheers.

@agoransson
Copy link

agoransson commented Dec 5, 2024

I'm having similar issue, but it only happens when trying to use SkiaFrameProcessors - normal frame processors seem to work for me although it can be a bit of a hassle to do things in correct order. Seems a bit fragile during build if something is a little bit off.

    "react-native": "0.76.3",
    "react-native-vision-camera": "^4.6.3",
    "react-native-worklets-core": "^1.5.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants