RN 签名打包 Error: Duplicate resourc
tool":"Resource and asset merger"
找到react-native文件夹下的react.gradle文件
在doFirst下加入以下代码
doLast {
//这里是打包时drawable图片报错
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()
//这里是打包时assets文件夹里的资源错误
File oriDir = file("$buildDir/generated/res/react/release/raw");
if (oriDir.exists()) {
File destDir = file("$buildDir/../src/main/res/raw");
ant.move(file: oriDir, tofile: destDir);
}
}