在React Native上生成apk失败

时间:2020-05-04 13:49:04

标签: react-native gradle build.gradle react-native-android react-navigation

当我使用此命令构建React本机项目时

gradlew bundleRelease

Task :app:mergeReleaseResources上犯了一个大错误

失败:构建失败,并出现异常。

  • 出了什么问题: 任务':app:mergeReleaseResources'的执行失败。

    [drawable-hdpi-v4 / node_modules_reactnavigation_stack_src_views_assets_backicon] C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ src \ main \ res \ drawable-hdpi \ node_modules_reactnavigation_stack_src_back_hcp_views_ets -v4 / node_modules_reactnavigation_stack_src_views_assets_backicon] C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ build \ Generated \ res \ react \ release \ drawable-hdpi \ node_modules_reactnavigation_stack_src_views_assets_backicon。 [drawable-mdpi-v4 / node_modules_reactnavigation_stack_src_views_assets_backicon] C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ src \ main \ res \ drawable-mdpi \ node_modules_reactnavigation_stack_src_views_assets_backets C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ build \ Generated \ res \ react \ release \ drawable-mdpi \ node_modules_reactnavigation_stack_src_views_assets_backicone.png:错误: [drawable-mdpi-v4 / node_modules_reactnavigation_stack_src_views_assets_backiconmask] C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ src \ main \ res \ drawable-mdpi \ node_modules_reactnavigation_stack_src_views_assets_backetsmask [png C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ build \ Generated \ res \ react \ release \ drawable-mdpi \ node_modules_reactnavigation_stack_src_views_assets_backiconmaske.png:错误: [drawable-mdpi-v4 / src_assets_address_emptyaddress] C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ src \ main \ res \ drawable-mdpi \ src_assets_address_emptyaddress.png [drawable-mdpi-v4 / src_assets_address_emptyaddress] [C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ build \ Generated \ res \ react \ release \ drawable-mdpi \ src_assets_address_emptyaddress.png:错误:资源重复 [drawable-mdpi-v4 / src_assets_address_faildelivery] C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ src \ main \ res \ drawable-mdpi \ src_assets_address_faildelivery.png [drawable-mdpi-v4 / src_assets_address_faildelivery] C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ build \ Generated \ res \ react \ release \ drawable-mdpi \ src_assets_address_faildelivery.png:错误:资源重复 [drawable-mdpi-v4 / src_assets_brands_bayer] C:\ Users \ victo \ Documents \ git \ melhor \ app-user \ android \ app \ src \ main \ res \ drawable-mdpi \ src_assets_brands_bayer.png [drawable-mdpi-v4 / src_assets_brands_bayer]

此错误更大,并且具有更多的“重复资源”。

我看到应用程序中使用的图像存在问题,但是那只是一个名称与应用程序内名称相同的图像,为什么会“重复”?

其他在我无法控制的导航上的资产,例如“ node_modules_reactnavigation_stack_src_views_assets_backicon”资产。

1 个答案:

答案 0 :(得分:0)

之所以会出现此问题,是因为项目构建了重复文件。

要解决此问题,您需要删除res文件夹中的文件。

删除drawable文件夹和raw文件夹。

您的项目目录如下:

enter image description here