16

Today I got update for android studio 2.0 in stable version.

I update it and it restarted.

Then when It opens my existing project, it ask me to update my gradle plugin to 2.0 to get advantages of "instant run" and other features to my current project of android studio 2.0

So I update it and it sets to

classpath 'com.android.tools.build:gradle:2.0.0'

but when I clean the project it gives me below error

AAPT err(Facade for 1961798984): libpng error: Read Error.

Error:Execution failed for task ':app:mergeDebugResources'.

Some file crunching failed, see logs for details

I tried to fixed it many times but it didn't solve.

Can anyone know what is the reason for this error ?

Jayesh
  • 3,661
  • 10
  • 46
  • 76

11 Answers11

42

You can try to add this to your app build.gradle file

 android {
    aaptOptions {  
                cruncherEnabled = false  
            } 
        }
Hoshouns
  • 2,420
  • 23
  • 24
  • Doing this helped expose the incorrect references and files to go and fix. Make sure to clear cache and rebuild. – DoctorD May 08 '17 at 20:14
  • 4
    didn't work for me due to corrupted png files, I had to reconvert them in tinypng.com – Junior Mayhé Jun 02 '17 at 15:39
  • yes fixed. But don't know about this.. can you explain? – Ranjithkumar Sep 11 '17 at 13:00
  • The aapt tool does not shrink PNG files contained in the asset/ folder. Image files need to use 256 or fewer colors for the aapt tool to optimize them. The aapt tool may inflate PNG files that have already been compressed. To prevent this, you can use the cruncherEnabled flag in Gradle to disable this process for PNG files: – Hoshouns Sep 27 '17 at 12:09
10

I ran into this problem in the past and did just back the version down. Today when I upgraded to AS 2.0, I got the same problem with the images. I did have to hunt down the offending images (there were 2 in my case) and had my designer re-export them.

Here's how I diagnosed (I'm on a mac FYI):

./gradlew :app:mergeIntegrationDebugResources --debug > buildLog.txt

Once that finished, I opened up the buildLog.txt file, and searched for "Error" (no quotes in actual search). I saw which file was having problems, and then removed it from the appropriate folder, and then re-ran the command above until I didn't get any errors.

I then sent the files that were having problems to my designer and had them re-exported.

Hope this helps!

oddmeter
  • 754
  • 7
  • 16
6

I've ran into this issue a couple times. The issue I've found is that an asset is either corrupted or has the wrong file extension. In my case it's usually a corrupted image I'd get from the art department. Once I removed the offending file, everything would compile and run just fine.

Basically what's happening is that Android is trying to compress and format the assets and resources, but if one of them is corrupted then it fails.

So try removing any recently added assets or resources.

Jeff
  • 133
  • 2
  • 8
3
aaptOptions {
        cruncherEnabled = false
}

Add the above line to your application module build.gradle

Clear the build cache Similar to the Android plugin's clean task that clears your project’s build/ directories, you can run the cleanBuildCache task to clear your project’s build cache. If a project specifies a non-default directory for its build cache, running the task from that project clears only that cache (and not the shared cache in the default location). To execute the task, select View > Tool Windows > Terminal from the menu bar and use one of the following commands:

On Windows:

gradlew cleanBuildCache

On Mac or Linux:

./gradlew cleanBuildCache
Askarc Ali
  • 318
  • 4
  • 21
3

in my case it was a png with size 0 in one of the folders.

Ignacio Tomas Crespo
  • 3,401
  • 1
  • 20
  • 13
2

i had the same issue.

in my case it happends after i added 9-patch file to the project.

Problem: one of the patches arount the image is missing.

Fix: double click on the 9-patch file. make sure you set the patches in all sides (up,down,right,left).

in my case this was the only solution after i tried many things

ggcarmi
  • 458
  • 4
  • 17
1

Please add the below code inside android {} in build.gradle (Module:app)

aaptOptions {  
                cruncherEnabled = false  
            } 

PFA screenshotApp Gradle Build

Ayan Pan
  • 21
  • 2
1

do not change file extension while pasting into the drawable folder... Some error may occur due to that change (ex: logo.PNG to logo.png )... to avoid this kind of problem you should edit extension before pasting into the drawable.

Sanjoy Kanrar
  • 899
  • 8
  • 11
1
simple answer works for sure....

just add below code in the build.gradle(Module:app) of your project:

android {
    aaptOptions {
        cruncherEnabled = false
    }
}

example:

enter image description here

Works 100%...@Ambilpur

0

This problem is caused generally by errors inside the resources files,

Some file crunching failed, see logs for details

most of the times we only see this message all the time, but to have a better diagnostic, delete the folders /build and his contain in your proyect, then the real problemas will show:

enter image description here

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
-4

Lower down the gradle version in build.graddle file to 1.3.0

 dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
 }
Ajay
  • 111
  • 2
  • It was already set 1.3.0 before an update and it's work perfectly in version 1.3.0, But I want to migrate in gradle 2.0.0 – Jayesh Apr 08 '16 at 11:17
  • You can't just lower your gradle version because doing so might lead to alot of refactoring of the code. – berrytchaks Jun 29 '17 at 16:23