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

Build Failure Due to Duplicate libreactnative.so File in Realm and React-Android #6918

Closed
Jean-Diniz opened this issue Nov 1, 2024 · 6 comments · Fixed by #6920
Closed

Comments

@Jean-Diniz
Copy link

How frequently does the bug occur?

Always

Description

When building the app with Gradle, the build process fails due to a duplicate libreactnative.so file. I expected the app to build and install without issues, but instead, the build fails with an error indicating that there are two instances of libreactnative.so, one from the realm library and another from react-android. This conflict prevents the app from installing.

Stacktrace & log output

Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction 
> 2 files found with path 'lib/arm64-v8a/libreactnative.so' from inputs: 
-/home/foobar/project/node_modules/realm/binding/android/build/intermediates/library_jni/debug/copyDebugJniLibsProjectOnly/jni/arm64-v8a/libreactnative.so 
- /home/foobar/.gradle/caches/8.10.2/transforms/095f498f1545b2a557a515b33db49b37/transformed/jetified-react-android-0.76.1-debug/jni/arm64-v8a/libreactnative.so

Can you reproduce the bug?

Always

Reproduction Steps

{
  "name": "foobar",
  "version": "0.0.0",
  "private": true,
  "packageManager": "yarn@3.6.4",
  "engines": {
    "node": "18.17.0"
  },
  "scripts": {
    "android": "APP_ENV=development react-native run-android",
  },
  "dependencies": {
    "react": "18.3.1",
    "react-native": "0.76.1",
    "realm": "12.13.2",
  },
  "devDependencies": {
    "@babel/core": "7.25.2",
    "@babel/preset-env": "7.25.3",
    "@babel/preset-typescript": "7.18.6",
    "@babel/runtime": "7.25.0",
    "@react-native-community/cli": "15.0.0",
    "@react-native-community/cli-platform-android": "15.0.0",
    "@react-native-community/cli-platform-ios": "15.0.0",
    "@react-native/babel-preset": "0.76.1",
    "@react-native/eslint-config": "0.76.1",
    "@react-native/metro-config": "0.76.1",
    "@react-native/typescript-config": "0.76.1",
  }
}
  • cd android
  • ./gradlew clean && cd ../
  • yarn
  • yarn android

Version

12.13.2

What services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Android 12

Build environment

OS: [Ubuntu 22.04]
Node.js: 18.17.0
React Native: 0.76.1
Gradle: 8.10.2
Java 17.0.7-zulu

Cocoapods version

No response

Copy link

sync-by-unito bot commented Nov 1, 2024

➤ PM Bot commented:

Jira ticket: RJS-2916

@mtalhadev
Copy link

For temporary fixing it, you can do this:

./node_modules/realm/binding/android/build.gradle

Add this one line in the excludes array.
packagingOptions {
excludes = [
"META-INF",
"META-INF/",
"
/libc++_shared.so",
"/libfbjni.so",
"
/libjsi.so",
"/libreactnativejni.so",
"
/libturbomodulejsijni.so",
"**/libreactnative.so", //Add this line
]
}

@joergjaeckel
Copy link

For whatever reason I also had to change "/libjsi.so" to "**/libjsi.so".

@edritech93
Copy link

still issue
"react-native": "0.76.1",
"realm": "12.13.2",

@kraenhansen
Copy link
Member

@edritech93 right. The PR is merged, however this is yet to be released.

@kraenhansen
Copy link
Member

The fix for this has been released as v12.14.0. Please help us take it for a spin 🙏

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

Successfully merging a pull request may close this issue.

5 participants