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

React-native Android build error: no compatible library found for //ReactAndroid/fabricjni #13

Closed
mpinter opened this issue Jul 12, 2024 · 4 comments

Comments

@mpinter
Copy link

mpinter commented Jul 12, 2024

Hello. Thanks for the project, I'm trying to get the example running locally on Android. The error I've been stuck with is the following:

> Task :gutenye_ocr-react-native:configureCMakeDebug[arm64-v8a] FAILED
C/C++: /Users/martinpinter/code/ocr/node_modules/@gutenye/ocr-react-native/android/CMakeLists.txt debug|arm64-v8a : com.google.prefab.api.NoMatchingLibraryException: No compatible library found for //ReactAndroid/fabricjni. Rejected the following libraries:

Entire log:

➭ npx expo run:android
› Building app...
Configuration on demand is an incubating feature.

> Configure project :gutenye_ocr-react-native
Download https://github.com/nihui/opencv-mobile/releases/download/v27/opencv-mobile-4.9.0-android.zip
Download https://repo1.maven.org/maven2/com/microsoft/onnxruntime/onnxruntime-android/1.17.3/onnxruntime-android-1.17.3.aar
WARNING: C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
WARNING: C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
WARNING: C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
WARNING: C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
WARNING: C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
WARNING: C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
WARNING: C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
WARNING: C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
WARNING: C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
WARNING: C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp
C/C++: Unable to parse STL from build.gradle arguments: c++_shared -mfloat-abi=softfp

> Configure project :expo

Using expo modules
  - expo-constants (15.4.6)
  - expo-file-system (16.0.9)
  - expo-font (11.10.3)
  - expo-image-loader (4.6.0)
  - expo-image-manipulator (11.8.0)
  - expo-image-picker (14.7.1)
  - expo-keep-awake (12.8.2)
  - expo-modules-core$android-annotation-processor (1.11.13)
  - expo-modules-core$android-annotation (1.11.13)
  - expo-modules-core (1.11.13)


> Task :gutenye_ocr-react-native:configureCMakeDebug[arm64-v8a] FAILED
C/C++: /Users/martinpinter/code/ocr/node_modules/@gutenye/ocr-react-native/android/CMakeLists.txt debug|arm64-v8a : com.google.prefab.api.NoMatchingLibraryException: No compatible library found for //ReactAndroid/fabricjni. Rejected the following libraries:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':gutenye_ocr-react-native:configureCMakeDebug[arm64-v8a]'.
> [CXX1212] /Users/martinpinter/code/ocr/node_modules/@gutenye/ocr-react-native/android/CMakeLists.txt debug|arm64-v8a : User is using a static STL but library requires a shared STL [//ReactAndroid/fabricjni]

* 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 8s
259 actionable tasks: 11 executed, 248 up-to-date
Error: /Users/martinpinter/code/ocr/packages/react-native/example/android/gradlew exited with non-zero code: 1
Error: /Users/martinpinter/code/ocr/packages/react-native/example/android/gradlew exited with non-zero code: 1
    at ChildProcess.completionListener (/Users/martinpinter/code/ocr/node_modules/@expo/cli/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)
    at Object.onceWrapper (node:events:628:26)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1091:16)
    at ChildProcess._handle.onexit (node:internal/child_process:302:5)
    ...
    at Object.spawnAsync [as default] (/Users/martinpinter/code/ocr/node_modules/@expo/cli/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)
    at spawnGradleAsync (/Users/martinpinter/code/ocr/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:72:46)
    at Object.assembleAsync (/Users/martinpinter/code/ocr/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:52:18)
    at runAndroidAsync (/Users/martinpinter/code/ocr/node_modules/@expo/cli/build/src/run/android/runAndroidAsync.js:36:24)

Can you please help me with getting the react native (expo) example running on Android device ? Thanks a lot in advance.

Note: had to make a few edits to library code before I got to this error - i.e. there is a release url referenced in gradle which was no longer valid and was replaced with https://github.com/nihui/opencv-mobile/releases/download/v27/opencv-mobile-4.9.0-android.zip. These seem harmless enough but if you'd like to see them as well happy to provide.

Note2: as farbic is mentioned in error, I tried to run the same code but toggling the "newArchitecture" option in gradle.options to true - this fails elsewhere.

@gutenye
Copy link
Owner

gutenye commented Jul 15, 2024

The error is User is using a static STL but library requires a shared STL

Can you give this a try? google/oboe@583c0af

@gutenye
Copy link
Owner

gutenye commented Jul 15, 2024

I have this one defined here

@gutenye
Copy link
Owner

gutenye commented Jul 15, 2024

From the ChatGPT

The error you’re seeing is related to a mismatch between the expected type of Standard Template Library (STL) the project is using (static vs shared) when building native code. Specifically, the message indicates that the user is using a static STL, but the library ReactAndroid/fabricjni requires a shared STL.

Here are some steps you can take to try to resolve this issue:

  1. Modify CMakeLists.txt to Use Shared STL:Open the CMakeLists.txt file in the directory given (node_modules/@gutenye/ocr-react-native/android/CMakeLists.txt) and explicitly set the STL type to be shared:
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANDROID_STL=c++_shared")

  2. Modify build.gradle to Support Shared STL:If modifying the CMakeLists.txt doesn’t resolve the issue, you can also set the STL type in your build.gradle file. In your app’s build.gradle file, under the android block, add the following line:
    android {
    externalNativeBuild {
    cmake {
    // Add this line to enable shared STL
    arguments "-DANDROID_STL=c++_shared"
    }
    }
    }

  3. Check Dependencies:Make sure that all dependencies are correctly set up to use the same type of STL. Sometimes, third-party libraries might create conflicts if they’re built with different STL configurations.

  4. Clean and Rebuild:It’s always a good practice to clean the project and try rebuilding it after making changes to configuration files. You can do this by running:
    cd android
    ./gradlew clean
    cd ..
    npx expo run:android

  5. Update Dependencies:Ensure that all dependencies are up-to-date, including the expo and react-native SDKs, as updates often fix compatibility issues. You can update the dependencies using:
    npm install -g expo-cli
    expo upgrade

  6. Use Debugging Options:If the problem persists, get more detailed logs by running Gradle with the --info or --stacktrace option to better understand where the conflict arises:
    npx expo run:android --info

By following these steps, you should be able to mitigate or resolve the STL conflict and proceed with the build. If the issue still exists, refer to the relevant documentation or reach out to the community for more specific guidance.

@gutenye
Copy link
Owner

gutenye commented Oct 11, 2024

Closed without response

@gutenye gutenye closed this as completed Oct 11, 2024
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

2 participants