不废话直接上报错
Execution failed for task ':app:mergeReleaseResources'.
[drawable-xhdpi-v4/resource_img_home_bg] /Users/dongxin/lt/front/app/android/app/src/main/res/drawable-xhdpi/resource_img_home_bg.png [drawable-xhdpi-v4/resource_img_home_bg] /Users/dongxin/lt/front/app/android/app/build/generated/res/react/release/drawable-xhdpi-v4/resource_img_home_bg.png: Error: Duplicate resources

解决方法
1、在node_modules/react-native/react.gradle
添加
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() }看准位置 不是在doFirst块内 !!!

2、清除缓存
在android Studio 中清缓存

3、重新打包
android目录下 ./gradlew assembleRelease
成功!!!!!