I have a lot of different flavors for my build that have specific resources and I don\'t want to clutter my src directory in my project with a bunch of flavor-specific direc
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")
}
}
}
For me delete all build folders and restart system and reopen Android Studio works in debug mode.
Update:
One of my png was giving error : error: failed to read PNG signature: file does not start with PNG signature
I open and export again in png. Now it is working with every build variant. And Delete one zero byte png. Anyone make it beautiful if works/ Thanks
You need to clean up your older caches of gradle and maven dependencies. E.g, try to delete the files under .m2
and .gradle
and then Invalidate Caches / Restart ...
Also, can try to disable enableAapt2
by setting it to false inside gradle.properties
android.enableAapt2=false
You need to verify your layout.xml files. There may be something wrong. I got same error and fixed issue on layout file. It worked for me.
If you would change variants it would automatically configure itself... Means if you are going run free(Choose from built Variants) then paid flavor will be red and Vice-Versa.
Solution:-
Just deleted drawable-xxxhdpi\background_4.png and re-generated android resources by running ionic cordova resources android --force