Skip to content

Issue with react-native-sodium blocks Android builds with latest Gradle version #27

@kaxline

Description

@kaxline

Here's the error I received immediately after installing react-native-etebase:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-sodium:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
   > 2 files found with path 'lib/armeabi-v7a/libsodium.so'.
     If you are using jniLibs and CMake IMPORTED targets, see
     https://developer.android.com/r/tools/jniLibs-vs-imported-targets

The problem is explained in the link from the error, but it ultimately appears to be the react-native-sodium dependency that's at fault.

I was able to get it working by editing the react-native-sodium grade.build file like this:

    sourceSets {
        main {
//            jniLibs.srcDirs = ['./lib']
        }
    }

But of course this will be overwritten whenever the package is updated or reinstalled. I don't know enough about Gradle to overwrite this in my project's gradle.build, so if anyone knows how to do that, I think it would be helpful.

This could potentially happen with other packages as well, not just react-native-sodium. Here's how other people have solved the issue, but the solutions didn't work for me:

https://stackoverflow.com/questions/62088079/error-when-building-project-with-ndk-support-after-updating-to-android-studio-4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions