Execution failed for task 'app:mergeDebugResources' Crunching Cruncher....png failed
In my case, the error was caused by a PNG file I added to the drawable folder. I had changed its extension from jpg to png by changing the text (in an inproper way) and then uploading it as PNG.
This was the problem Android Studio was pointing to.
I fixed this problem and got the error to disappear by changing the file extension using the Paint.NET tool or any other tool (proper way), and then uploading it to the drawable folder.
I fixed this issue by moving the project to the outer directory, and it then compiled successfully.
It was due to the long path of the project directory.
For example, I moved the project from:
D:/Android/Apps/AndroidStudioProject/AppName
to
D:/Android/AppName
This is due to adding an image in drawable which has some extension like (.jpg), and you have changed or saved that to a .png format (this error will occur while changing the image format manually without using an editor tool).
Android Studio will throws an error while compiling the resource package using AAPT (Android Asset Packaging Tool), so all you need to do is use some image editor tools like GIMP or Paint to save the extension accordingly. Rebuild your project once everything is done.
For example: open your image in Paint (drag and drop your image to open it) → menu File → Save As → Save as Type → select your required type from the dropdown like I have shown in the below pictures:
In my case the solution was simple. I moved the entire project to another location where the path is short.
The problem was caused by long directory names and file names.
The best solution is to change buildDir in build.gradle:
For example:
allprojects {
buildDir = "C:/tmp/${rootProject.name}/${project.name}"
repositories {
jcenter()
}
}
Rebuild and happy coding.