build failing during merge resources with Android Gradle plugin 3.3.0
I had the same issue. The build would break and mention different png files, like your background_4.png, but only on a Windows PC. The build on a Mac had no problems.
In my case the image size was the problem. Only images bigger than 2MB seamed to break the build. After reducing every image to something lesser than 2MB the build started working again.
Check your layout xml files carefully in my case issue was duplicate xml
<?xml version="1.0" encoding="utf-8"?>
Updated 19th April, 2019
This issue has been fixed in Android Gradle Plugin 3.4.0
.
After upgrading to Android Studio 3.4.0, the temporary fix suggested in the original answer can be removed. Hurray!
Original
This is a bug in AAPT2 in Android Gradle Plugin 3.3.0, when building a project with larger png's (around 2-3 mb and up).
@akong9759 created an issue for this on Googles issue tracker and it has been fixed.
https://issuetracker.google.com/issues/117900475
The problem has been fixed in Android Gradle Plugin 3.5.0-alpha03 and the fix is scheduled to be released in version 3.4.0.
A temporary fix for Android Gradle Plugin 3.3.0 has been suggested on the issue. Add the following to the project build.gradle
:
allprojects {
// Workaround for https://issuetracker.google.com/117900475
// Remove when upgrading to AGP 3.4 or higher.
configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
config.resolutionStrategy.eachDependency { details ->
details.useVersion("3.5.0-alpha03-5252756")
}
}
}