android 打包报错,React Native Android打包报错系列

1.Exception in thread "main" java.util.zip.ZipException: error in opening zip file

解决方法:

这是解压gradle-x.x-all.zip文件报错,原因是在你创建工程gradle-x.x-all包下载不完全或者没有下载。

我用的版本是:gradle-4.6-all

1.先去下载你的版本的gradle压缩包:http://services.gradle.org/distributions/

2.放在/Users/xxx/.gradle/wrapper/dists/gradle-4.6-all/bcst21l2brirad8k2ben1letg下,重新运行就行了

2.Execution failed for task ':app:mergeReleaseResources'. ...xxx_xxx_xxx.png: Error: Duplicate resources

Mapsy's answer should help https://stackoverflow.com/a/52750886

So basically you edit the /node_modules/react-native/react.gradle file

and add the doLast right after the doFirst block, manually.

doFirst { ... }

doLast {

def moveFunc = { resSuffix ->

File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");

if (originalDir.exists()) {

File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");

ant.move(file: originalDir, tofile: destDir);

}

}

moveFunc.curry("ldpi").call()

moveFunc.curry("mdpi").call()

moveFunc.curry("hdpi").call()

moveFunc.curry("xhdpi").call()

moveFunc.curry("xxhdpi").call()

moveFunc.curry("xxxhdpi").call()

}

方案二:参考https://blog.youkuaiyun.com/github_34437042/article/details/81150462

在使用gradle 4.7版本进行打包的时候,node_modules_reactnavigation_src_views_assets_backicon.png会出现图片重复的问题

首先修改getAndroidAssetSuffix文件:node_modules\react-native\local-cli\bundle\assetPathUtils.js

在这里面需要修改部分代码:

文件中的原代码

function getAndroidAssetSuffix(scale) {

switch (scale) {

case 0.75: return 'ldpi';

case 1: return 'mdpi';

case 1.5: return 'hdpi';

case 2: return 'xhdpi';

case 3: return 'xxhdpi';

case 4: return 'xxxhdpi';

}

}

修改后代码

function getAndroidAssetSuffix(scale) {

switch (scale) {

case 0.75: return 'ldpi-v4';

case 1: return 'mdpi-v4';

case 1.5: return 'hdpi-v4';

case 2: return 'xhdpi-v4';

case 3: return 'xxhdpi-v4';

case 4: return 'xxxhdpi-v4';

}

}

之后再将android.../res文件夹下的drawable所有文件都删除。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值