17

我将 react-native-pdf 安装到我的项目中,当我使用“npx react-native run-android”运行时发生失败并显示如下错误

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

谁能帮助我可以使用包 react-native-pdf

我有

4

4 回答 4

39

我有同样的问题,我通过将以下内容添加到 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 **/

}

于 2020-09-29T09:06:01.063 回答
1

在 Android Studio android 中打开项目并清理项目 Build -> Clean Project

于 2021-03-25T16:51:17.293 回答
1

将此代码添加到“/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'
  }
  /** .... **/
}

所以在终端上运行

$ cd android/
$ ./gradlew cleanBuildCache
$ cd ..
$ sudo npx react-native run-android
于 2021-10-18T17:57:40.153 回答
-1

我在“android/app/build.gradle”中将 minSdkVersion 更改为 21。

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
    }
于 2021-01-09T08:45:32.990 回答