'Execution failed for task ':app:mergeDebugNativeLibs'. in react native

I installed react-native-pdf and now when I run "npx react-native run-android", it fails with the following:

* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > More than one file was found with OS independent path 'lib/x86/libc++_shared.so'

Can anyone help me use the package react-native-pdf?

ive



Solution 1:[1]

I had the same issue and i resolved it by adding the following to android/app/build.gradle

android {

packagingOptions {
    pickFirst 'lib/x86/libc++_shared.so'
    pickFirst 'lib/x86_64/libc++_shared.so'
    pickFirst 'lib/armeabi-v7a/libc++_shared.so'
    pickFirst 'lib/arm64-v8a/libc++_shared.so'
}

/** rest of your code here **/

}

Solution 2:[2]

Add this code to "/android/app/build.gradle"

android {
  packagingOptions {
      pickFirst 'lib/x86/libc++_shared.so'
      pickFirst 'lib/x86_64/libc++_shared.so'
      pickFirst 'lib/armeabi-v7a/libc++_shared.so'
      pickFirst 'lib/arm64-v8a/libc++_shared.so'
  }
  /** .... **/
}

So run this on the terminal

$ cd android/
$ ./gradlew cleanBuildCache
$ cd ..
$ sudo npx react-native run-android

Solution 3:[3]

Open the project in Android Studio android and clean the project Build -> Clean Project

Solution 4:[4]

i changed minSdkVersion to 21 in "android/app/build.gradle".

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.custom_epub_view"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Edward Tshifaro
Solution 2 Pedro Oliveira
Solution 3 Preetam
Solution 4 AliReza KazemiNezhad