build failing during merge resources with Android Gradle plugin 3.3.0

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")
        }
    }
}

Leave a Comment

tech