React Native 0.57.1 Android Duplicate Resources
Recent versions of React Native (>0.57.0) have increased the Gradle wrapper level to 4.4 and Gradle plugin to 3.1.4, as indicated by the changelog. This has the effect of making the Gradle build process store the results of AAPT, which are now required, within a different directory than previously. So basically you have to 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()
}
Had the same error. What I did to resolve it:
- delete all the pictures in the drawable folder android/app/src/main/res
- generate apk cd android && gradlew assembleRelease
Here is the simple solution :
- Delete build inside android/app folder
- Delete build inside android folder
- run
rm -rf $HOME/.gradle/caches/
- Open build.gradle --> android/app/build.gradle
- comment this line
//apply from: "../../node_modules/react-native/react.gradle"
Delete
index.android.bundle
file from assets folder and re-create usingreact-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
run
react-native run-android
Or runreact-native run-android --variant=release
Happy Coding..