React本机gradlew assembleRelease构建失败。任务':app:mergeReleaseResources'的执行失败

时间:2020-04-04 06:44:32

标签: android ios react-native gradle react-native-android

运行./gradlew assembleRelease时遇到此错误。我已经几个小时了。帮助请。它曾经成功构建,但是在我尝试清除某些内容并结合git历史记录中的其他文件夹后,没有任何办法可以挽救。


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> [raw/app] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/app.json [raw/app] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/app.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_materialcommunityicons] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_materialcommunityicons.json[raw/node_modules_reactnativevectoricons_glyphmaps_materialcommunityicons] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_materialcommunityicons.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free_meta] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free_meta.json[raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free_meta] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free_meta.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome.json[raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_fontisto] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_fontisto.json   [raw/node_modules_reactnativevectoricons_glyphmaps_fontisto] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_fontisto.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_feather] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_feather.json[raw/node_modules_reactnativevectoricons_glyphmaps_feather] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_feather.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_entypo] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_entypo.json   [raw/node_modules_reactnativevectoricons_glyphmaps_entypo] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_entypo.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_ionicons] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_ionicons.json   [raw/node_modules_reactnativevectoricons_glyphmaps_ionicons] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_ionicons.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free.json   [raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_fontawesome5free.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_simplelineicons] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_simplelineicons.json[raw/node_modules_reactnativevectoricons_glyphmaps_simplelineicons] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_simplelineicons.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_evilicons] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_evilicons.json [raw/node_modules_reactnativevectoricons_glyphmaps_evilicons] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_evilicons.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_materialicons] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_materialicons.json [raw/node_modules_reactnativevectoricons_glyphmaps_materialicons] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_materialicons.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_antdesign] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_antdesign.json [raw/node_modules_reactnativevectoricons_glyphmaps_antdesign] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_antdesign.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_foundation] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_foundation.json   [raw/node_modules_reactnativevectoricons_glyphmaps_foundation] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_foundation.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_octicons] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_octicons.json   [raw/node_modules_reactnativevectoricons_glyphmaps_octicons] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_octicons.json: Error: Duplicate resources
  [raw/node_modules_nativebase_dist_src_basic_icon_nbicons] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_nativebase_dist_src_basic_icon_nbicons.json [raw/node_modules_nativebase_dist_src_basic_icon_nbicons] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_nativebase_dist_src_basic_icon_nbicons.json: Error: Duplicate resources
  [raw/node_modules_reactnativevectoricons_glyphmaps_zocial] /home/horhi/code/projects/ankilan/android/app/src/main/res/raw/node_modules_reactnativevectoricons_glyphmaps_zocial.json   [raw/node_modules_reactnativevectoricons_glyphmaps_zocial] /home/horhi/code/projects/ankilan/android/app/build/generated/res/react/release/raw/node_modules_reactnativevectoricons_glyphmaps_zocial.json: Error: Duplicate resources

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 58s
65 actionable tasks: 11 executed, 54 up-to-date

1 个答案:

答案 0 :(得分:3)

我今天有同样的错误消息。这些就是我为解决错误所做的事情。另外,我还添加了我以前做过的事情,以防它们相互关联:

来自此相关的Stackoverflow答案https://stackoverflow.com/a/55245362

1)删除 / android / app / build /...

2)删除 / android / build /...

3)注释 ./ android / app / build.gradle

中的apply from "../../node_modules/react-native/react.gradle"

4)删除 /android/app/src/main/assets/index.android.js

5)通过以下方式从项目的根文件夹中重新绑定:

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

在这里,我对OG答案稍加修改,自己决定要使用哪种方式

5)通过

通过 ./ android /...构建ReleaseBuild

.\gradlew assembleRelease

这对我有用。我之前做过的其他事情,以防它仍然对您不起作用:

  • 删除 ./ node_modules /...并通过npm installyarn install
  • 重新获取依赖项
  • 从项目根目录通过react-native link react-native-vector-icons链接react-native-vector-icons

希望有帮助!