- assembleDebug debug打包没有问题
- assembleRelease release打包在生成正式apk的时候就如下:
实际上就是多了以下资源文件,我们在每次编译的时候移除掉以下文件,就能解决此次问题
在 node_modules / react-native / react.gradle
dpFirst 下增加 doLast 如图:
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()
}
加入后重新打正式包即可
以上打包是在android studio
如需在webstorm打包,可在Terminal 执行
cd android
gradlew assembleReleasesembleRe