Error:Execution failed for task ':ProjectName:mergeDebugResources'. > Crunching Cruncher *some file* failed, see logs

AndroidAndroid StudioAndroid Gradle-Pluginbuild.gradle

Android Problem Overview


I have this error when trying to make a module of a project

apply plugin: 'com.android.library'

android {
    compileSdkVersion 17
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 8
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile files('libs/sdk.jar')
    compile files('libs/ads-lib.jar')
    compile project(':google-play-services_lib')
    compile files('libs/hdvdecoderandroid.jar')
}

How can i fix this error?

Edit

Here is my logs file, when i try to build it in command line

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':hDVietAndroid:m
ergeDebugResources'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAct
ions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(Ex
ecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.exe
cute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(Skip
UpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(Valida
tingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.exec
ute(SkipEmptySourceFilesTaskExecuter.java:42)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute
(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOn
lyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute
(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(Abstra
ctTask.java:305)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.ex
ecuteTask(AbstractTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.pr
ocessTask(AbstractTaskPlanExecutor.java:63)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.ru
n(AbstractTaskPlanExecutor.java:51)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPla
nExecutor.java:23)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGr
aphExecuter.java:88)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutio
nAction.java:29)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:6
2)
        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.jav
a:23)
        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java
:68)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionA
ction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:6
2)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:5
5)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLa
uncher.java:149)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher
.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.jav
a:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.
run(InProcessBuildActionExecuter.java:80)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildA
ctionExecuter.java:36)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildA
ctionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(
CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(
CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValida
tionAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValida
tionAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandL
ineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandL
ineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAc
tion.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAc
tion.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.jav
a:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.lang.RuntimeException: Crunching Cruncher vertbar.9.png failed, see logs

        at com.android.builder.png.QueuedCruncher.waitForAll(QueuedCruncher.java:178)
        at com.android.builder.png.QueuedCruncher.end(QueuedCruncher.java:190)
        at com.android.ide.common.res2.MergedResourceWriter.end(MergedResourceWriter.jav
a:128)
        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.doFullTaskAction(MergeResources
.groovy:112)
        at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(Incrementa
lTask.groovy:70)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$I
ncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:235)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$S
tandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$I
ncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:222)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$S
tandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAct
ion(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAct
ions(ExecuteActionsTaskExecuter.java:61)
        ... 47 more

I try to search in stackoverflow, but i can't find a correct answer for my case.

Android Solutions


Solution 1 - Android

As stated here this can happen when using the Gradle Tools v1.1.0. After updating to v1.1.3, this has not happened anymore.

Solution 2 - Android

Close android studio and open it again. Then try compiling the same code. I was getting the same error and it worked for me. Hope it helps.

Solution 3 - Android

It may happens because fake png files. You can use this command to check out fake pngs.

cd <YOUR_PROJECT/res/> && find . -name *.png | xargs pngcheck

And then,use ImageEditor(Ex, Pinta) to open fake pngs and re-save them to png.

Good luck.

Solution 4 - Android

Ok, I just faced this problem and tried all of the steps mentioned above but didn't help. So what I did, I checked what image extension it was before I renamed it to .png. In my case it was .jpeg. So I renamed it back to .jpeg and kept the same original file in drawable. And bingo, it just worked fine.

So the solution is, use the file without changing extension, be it .png or .jpeg, keep it the original way.

Thought to share if it helps anyone. Thanks.

Solution 5 - Android

I have had this problem before with adding png files. I have discovered the problem with some of them since cleaning your project and closing AS does not solve every problem.

I did an experiment with GIMP when exporting images. Apparently, converting them to RGB fixes it. Some photos will be set to Indexed mode. Simply select Image>Mode>RGB. Then, export it and copy it into AS.

Solution 6 - Android

I was getting the same error and it worked for me. Hope it helps.

> As Niklas said, you have to update to the latest Gradle version.


My way to solve the error:

  1. Open your Android Studio (AS) program.

  2. Go to your build.gradle file in your project.

  3. Change:

    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    

to:

    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.3'

4. Sync your Android project with Gradle: enter image description here

  1. Clean your project.
  2. Rebuild your project.
  3. Done!

If its still not working:

  1. Close your Android Studio program and open it again.
  2. Try compiling the code.
  3. Done!

If you need more help, read the issue on Google Code!

Solution 7 - Android

After using pngcheck and resave all my image files to *.png, the problem still.

Finally, I found the issue is about *.9.png files. Open and check all your 9-Patch files, make sure that all files have black lines as below, if don't have, just click the white place and add it, then save it.

9-Patch

Solution 8 - Android

I had faced this similar error too. In my case it was one of my picture files in my drawable folder. Removing the picture that was unused solved the problem for me. So, make sure to remove any unused items from drawable folder.

Solution 9 - Android

Additional to all answers, I think it could have similar problems. My Problem was caused by png.9 files. If this files, have a (in my case) too small stretching area with just a few pixels, the building failed with this error also. I have checked all these answers, but nothing helped. Giving a little bit bigger stretching area, solved the problem. I tested it many times, allways when I use small stretching areas it failed. So I am sure, it will help some poeple to make the stretch area a little bit bigger.

The second problem, but this is just an assumption, is the icon name (maybe only for png.9 files too). For examle, I used an image named folder_icon.9.png , with this one, it allways failed. Renaming it to other_folder_icon.9.png, it worked. So I think some names are used by the android system itself, maybe here is a problem too.

Solution 10 - Android

I faced the same error but i solved this by selecting invalidate caches/restart option.

Click

  1. file >> invalidate caches/restart

Solution 11 - Android

Sometimes, it can be caused by wrong naming for xml or resource file.

At least, for me, that problem was solved by changing name .

Solution 12 - Android

Clean the project and build it again

Solution 13 - Android

I came here because i had this problem and non of the answers here helped me. For future user that could be helped here:

My problem was I did two 9-patch images for a switch button. Then I rezized that image without 9-patching them. To solve the issue I had to 9-patch all the images for all the drawable folders (xxhdpi, xhdpi and so on)

Solution 14 - Android

The problem might probably be due to the mismatch of the extension types given by the programmer and the actual extensions of the images present in the drawable folder of your app. or fixing this follow the steps given below:-

Step 1- Double click on each of the image resources and and check the extension i.e whether the image is png or jpeg or any other format.

Step 2- Now check if the same extension is given by you in the drawable folder dropdown in package explorer(a.k.a Android in Android Studio).

Step 3 - If the extensions are not matching then delete that image and paste another image of the same name in its place making sure the extension is matching with the actual extension of the image (for example, if the image is "a.png" then make sure the extension of the image given by you is also of .png type) .

Step 4 - Sync your gradle file and run the project. This time there should be no errors.

Solution 15 - Android

Today I also met this problem. Here is how I solved it:

  1. I built the app, then I saw the errors in the message window. They said the picture (with the full path) was malformed.
  2. Then I found the malformed png which had the name xxx.9.png.
  3. I renamed it to xxx9.png and rebuilt. There were no errors, and the java files with the red wave under the name are gone too.

Solution 16 - Android

You can get this error if you have invalid 9-patch files. If there is anything apart from black and transparent in the border pixels you will get this error. The easiest way of fixing this is to open it up in Android Studio and modify the borders. Just adding and removing one pixel is enough.

It's worth noting that you won't see the bad pixels in AS, as the editor sets anything not black to transparent, but you will need to modify the file for it to save these changes.

Solution 17 - Android

I had the same problem.

It was caused by a corrupted file. If you added some new Drawable before getting this error, check them to see if they are correctly display in Android Studio Viewer.

Solution 18 - Android

I have tried methods mentioned above, restarting the AS didn't work for me, and rebuilding didn't work either. Finally I found the problem was with the .9.png files, I deleted them and rebuilt the project, and it worked fine! Try it.

Solution 19 - Android

I had the same problem, but look at this image and I`m sure u can find the answer in such situation...the problem was in a png file. when I fixed what android studio asked me, it worked. I hope it works for U too. click this photo... it shows where is the problem and what it is

Solution 20 - Android

I was also stuck by this problem.But in my case I delete all .png images from drawable folder ,clean and rebuild application and then paste all .png images to my drawable, rebuild again. It worked fine for me.

Solution 21 - Android

Even i had same problem,this solution helped me so it might help you

check build version is matching with compile sdk version and add below code inside android block of build.gradle

buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

Solution 22 - Android

This could also some extra reasons instead of the mentioned reasons :

  • You have a crashed image : one of your images cannot be load
  • adding an image to the drawable folder and modifying it's type (png ,jpg) while giving it a name(or inside the drawable folder using the rename function)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionmr.iceteaView Question on Stackoverflow
Solution 1 - AndroidNiklasView Answer on Stackoverflow
Solution 2 - AndroidTejas PawarView Answer on Stackoverflow
Solution 3 - AndroidShengfeng LiView Answer on Stackoverflow
Solution 4 - AndroidjustLearningView Answer on Stackoverflow
Solution 5 - AndroidDaniel MillsView Answer on Stackoverflow
Solution 6 - AndroidSuriyaaView Answer on Stackoverflow
Solution 7 - AndroidBobGaoView Answer on Stackoverflow
Solution 8 - AndroidmarinView Answer on Stackoverflow
Solution 9 - AndroidOpiatefuchsView Answer on Stackoverflow
Solution 10 - Androidyubaraj poudelView Answer on Stackoverflow
Solution 11 - AndroidelifekizView Answer on Stackoverflow
Solution 12 - AndroidChatura DilanView Answer on Stackoverflow
Solution 13 - Androidrain_View Answer on Stackoverflow
Solution 14 - AndroidAamir AhmedView Answer on Stackoverflow
Solution 15 - Androiduser2459500View Answer on Stackoverflow
Solution 16 - AndroidTomWView Answer on Stackoverflow
Solution 17 - AndroidSofiane HassainiView Answer on Stackoverflow
Solution 18 - AndroidMindjetView Answer on Stackoverflow
Solution 19 - AndroidMNMView Answer on Stackoverflow
Solution 20 - AndroidUday SurseView Answer on Stackoverflow
Solution 21 - Androidsneha vView Answer on Stackoverflow
Solution 22 - AndroidAchref GassoumiView Answer on Stackoverflow