29

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

bartonstanley
  • 1,167
  • 12
  • 25
zainal abidin
  • 363
  • 1
  • 3
  • 12

8 Answers8

59

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 **/

}

Edward Tshifaro
  • 627
  • 4
  • 6
6

add this to your app/build.gradle

android {
   // yout existing code
   packagingOptions {
        pickFirst '**/libc++_shared.so'
        pickFirst '**/libfbjni.so'
    }
}
4

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

Preetam
  • 5,528
  • 10
  • 32
  • 39
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
0

For us, it was caused by react-native-pdf.

So either, eject the project and update build.gradle same as other answers say or, get rid of it if not used or you may replace it with rn-pdf-reader-js

Abdulrahman Hashem
  • 1,481
  • 1
  • 15
  • 20
0

For me its gradle cache issue, I fixed it by running running the following command in the project's root directory:

cd android

and after

./gradlew clean
DineshMsd
  • 72
  • 1
  • 9
-1

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
    }
-1

android build.gradle file under allprojects add following

allprojects {
   configurations.all {
   resolutionStrategy {
   force 'com.facebook.react:react-native:0.65.2' //select Version you used
   }
}

https://github.com/facebook/react-native/issues/35215#issuecomment-1304878829

مصطفى
  • 555
  • 4
  • 9