17

I am testing 9-patch image .
Before everything works fine , and i rename drawable file ic_button_beat_box_default.png to ic_button_beat_box_default.9.png , then i get error :

Some file crunching failed, see logs for details

. Then i rename back , it works normal. So how this happens ?

The complete error is :

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Some file crunching failed, see logs for details

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeDebugResources'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    ...
Caused by: java.lang.RuntimeException: Some file crunching failed, see logs for details
    at com.android.builder.png.QueuedCruncher.waitForAll(QueuedCruncher.java:260)
    at com.android.builder.png.QueuedCruncher.end(QueuedCruncher.java:280)
    at com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.java:132)
    at com.android.ide.common.res2.DataMerger.mergeData(DataMerger.java:291)
    at com.android.ide.common.res2.ResourceMerger.mergeData(ResourceMerger.java:48)
    at com.android.build.gradle.tasks.MergeResources.doIncrementalTaskAction(MergeResources.java:250)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:124)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:244)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:231)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 57 more
shaoyihe
  • 1,047
  • 1
  • 12
  • 28
  • Possible duplicate of [Execution failed for task 'app:mergeDebugResources' Crunching Cruncher....png failed](http://stackoverflow.com/questions/30764604/execution-failed-for-task-appmergedebugresources-crunching-cruncher-png-fa) – Heberth Jan 26 '17 at 16:07
  • I have problem Like that, and check the origin format of picture and change it with the origin fotmat is jpeg – Ryan Bagus Susilo Apr 30 '17 at 07:27

8 Answers8

39

On Windows I had a "BUILD FAILED Failed to crunch file [path]" error and solved it by closing the Android Studio project, copying the entire project folder into a location with a shorter directory path, such as my C: folder and then opening the project in the new location. Hope it helps

tomalf2
  • 524
  • 5
  • 8
  • This has to do with Windows path length limits when Bamboo is running on Windows Server. Solution: Build on Linux! – Ewoks Feb 01 '17 at 15:02
3

Rename your file again

ic_button_beat_box_default.9.png to ic_button_beat_box_default9.png because android studio takes ic_button_beat_box_default.9 instead of ic_button_beat_box_default.9.png

or another solution is add below line to your build.gradle(Module:app)

android{
 aaptOptions {cruncherEnabled = false} 
}
Abhishek kumar
  • 4,347
  • 8
  • 29
  • 44
Rahul
  • 219
  • 1
  • 10
  • 1
    +1 for writing the `android {...}` key. I am a react-native developer and know little about `build.gradle` structure – ofundefined Dec 18 '19 at 21:42
2

I had the same issue by changing only file name, when I saved the image in 9-patch-tool issue solved.

yoo
  • 31
  • 3
  • Same solution as mine using macOS. I just renamed bla.png to bla.9.png, then I opened it in android studio, modified in built-in editor and saved. – matusalem May 04 '17 at 10:05
1

I had the same issue. I was able to resolve it just by reducing one folder from chain. It is due to long file path. So try using minimum hierarchy for your project location.

Srushti
  • 131
  • 7
1

try this, insert this code in android section in app gradle:

aaptOptions {  
    cruncherEnabled = false  
}
Hamed Nikzad
  • 618
  • 8
  • 14
0

I have red other similar questions and answers to them on SO, regarding that "file crunching failed, see logs for details" error. Nothing helped.So,I reverted all "SO" changes I made with gradle and other files and removed ".9" in that png.9 files and it began work. Then I recreated all *.9.png files again. Hence, in my case the cause was wrong editing of 9.pngs in external png editors.

CodeToLife
  • 3,672
  • 2
  • 41
  • 29
0

What solved it for me was to set

aaptOptions {  
    cruncherEnabled = false  
}

Then to run the app (icons were missing) then remove this option and run the app again. Hope it helps somebody.

Sir Codesalot
  • 7,045
  • 2
  • 50
  • 56
0

This worked for me:

Build -> Clean Project.

and then

Build -> Rebuild Project.

Pinkesh Darji
  • 1,041
  • 10
  • 23