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

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.

The answer is


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.


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)


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.


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

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


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.


Clean the project and build it again


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.


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.

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.


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.


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.


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


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'
        }
    }

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


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.


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

Click

  1. file >> invalidate caches/restart

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.


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

  5. Clean your project.

  6. Rebuild your project.
  7. 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!


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)

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.


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.


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to android-gradle-plugin

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Android Material and appcompat Manifest merger failed Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries Invoke-customs are only supported starting with android 0 --min-api 26 error: resource android:attr/fontVariationSettings not found Exception : AAPT2 error: check logs for details Could not resolve com.android.support:appcompat-v7:26.1.0 in Android Studio new project Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)

Examples related to build.gradle

Android Material and appcompat Manifest merger failed Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve Android dependency has different version for the compile and runtime Setting up Gradle for api 26 (Android) What's the difference between implementation and compile in Gradle? More than one file was found with OS independent path 'META-INF/LICENSE' Android Studio - Failed to notify project evaluation listener error Gradle error: Minimum supported Gradle version is 3.3. Current version is 3.2 All com.android.support libraries must use the exact same version specification DELETE_FAILED_INTERNAL_ERROR Error while Installing APK