When running ./android/gradlew assembleRelease
I get the following error:
``` * What went wrong: Execution failed for task \':app:mergeReleaseResources\
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()
}
Remove raw file in src/main/res/raw
Then run This cmd=>
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/release/
Then go run /android=> agradlew assembleRelease
This problem will happen when you have 2 images with similar names and different types.
Just Check your assets and avoid naming the same.
If the build fails after executing Task :app:bundleReleaseJsAndAssets you will observe this error in the subsequent attempt
The easiest way to find the duplicate entries is through version control.
If you are using Git. You can get the all the Un-tracked files using the command
git status
& delete the files in /android/app/src/main/res/drawable** directories.
Re-run the build should work.
llya today I have faced a similar problem and fixed by following steps:
updated classpath 'com.android.tools.build:gradle:3.1.3' to classpath 'com.android.tools.build:gradle:3.2.0' in build.gradle.
changed distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip to distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip in /android/gradle/wrapper/gradle-wrapper.properties
Removed android.enableAapt2=false from gradle.properties
Updated buildToolsVersion:27.0.3
clean project
sync gradle again in android studio.
bundle and try again to make a release build.
I just deleted android/app/build/generated/
folder and the build succeded.