Java Android - 错误:任务 ':app:mergeDebugResources' 执行失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41084578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 23:08:37  来源:igfitidea点击:

Android - Error:Execution failed for task ':app:mergeDebugResources'

javaandroidgradle

提问by ec2ainun

please help me!

请帮我!

here is error says:

这是错误说:

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

Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:

错误:任务“:app:mergeDebugResources”的执行失败。

错误:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:

my app gradle is :

我的应用程序gradle是:

apply plugin: 'com.android.application'
android {
  compileSdkVersion 25
  buildToolsVersion "25.0.1"
  packagingOptions {
    exclude 'META-INF/NOTICE' // will not include NOTICE file
    exclude 'META-INF/LICENSE' // will not include LICENSE file
  }
defaultConfig {
    applicationId "com.aku.ec2ainun.stepondesign"
    minSdkVersion 18
    targetSdkVersion 25
    versionCode 1
    versionName "1.1"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
dexOptions {
    javaMaxHeapSize "4g"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}
dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
   androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.android.gms:play-services:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:multidex:1.0.1'
compile files('libs/slider.jar')
}
apply plugin: 'com.google.gms.google-services'

my project gradle:

我的项目gradle:

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    classpath 'com.google.gms:google-services:3.0.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
 }
}
allprojects {
  repositories {
    jcenter()
 }
}
task clean(type: Delete) {
   delete rootProject.buildDir
}

采纳答案by u5726725

Try code on your module build.gradle:

在您的模块上尝试代码build.gradle

android {
// ...
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
// ...
}

It means Android studio DO NOTcheck PNG strictly.

这意味着 Android studio严格检查 PNG。

回答by u6886354

maybe the image issue which u put into the mipmap ,delete the image and retry the gradle sync 汉语 就是你放到mipmap中的图片有问题 把他删了就好了 哎 真为我的英语捉急啊~~

可能是你放入mipmap的图片问题,删除图片重试gradle sync 汉语就是你现在mipmap中的图片有问题 把他有没有了 哎真真为我的英语捉急啊~~

回答by Kamta Sahu

I got the same issue when I insert png image to drawable folder. I delete that image,clean project and rebuild it , the issue resolved.This worked for me.

当我将 png 图像插入可绘制文件夹时,我遇到了同样的问题。我删除了那个图像,清理项目并重建它,问题解决了。这对我有用。

回答by Jogendra Gouda

Some times I also get this error

有时我也会收到此错误

Rebuilding the entire project before running (Build > Rebuild Project) it doesn't show up anymore.

在运行之前重建整个项目(Build > Rebuild Project)它不再出现。

You can try this.

你可以试试这个。

回答by BST Kaal

Check your resources, specially the file names. It sucks when android studio does not point out the real reason. It solved my issue.

检查您的资源,特别是文件名。当 android studio 没有指出真正的原因时,这很糟糕。它解决了我的问题。

回答by Ahsan Hayat

I got the same issue after I added 9 patch image in my project. Removing that image solved my problem.

在我的项目中添加 9 个补丁图像后,我遇到了同样的问题。删除该图像解决了我的问题。

回答by Bhupesh Ravish

I faced the same issue. I was using *.png files and the gradle Build kept on failing, despite multiple Rebuild-projects. Surprisingly, the moment I changed the file names from *.png to *.jpg, it worked!

我遇到了同样的问题。我正在使用 *.png 文件,尽管有多个重建项目,但 gradle Build 仍然失败。令人惊讶的是,当我将文件名从 *.png 更改为 *.jpg 时,它起作用了!

回答by diegocom

Try to check that, if you use a 9-patch image, it is in correct format (with black pixel on the edge and they mustn't touch the pixel of your image). I resolved this problem with changing a 9-patch image that is malformed. In my case the image touched the black pixel of 9-patch e android studio showed that error.

尝试检查一下,如果您使用 9-patch 图像,它的格式是否正确(边缘有黑色像素,并且它们不能接触图像的像素)。我通过更改格式错误的 9 块图像解决了这个问题。在我的情况下,图像触及 9-patch e android studio 的黑色像素显示该错误。

回答by Dr.Din

After struggling a lot I have final solve this issue:

经过一番挣扎,我终于解决了这个问题:

I realize two issue while solving this issue

我在解决这个问题时意识到两个问题

  1. kindly check each and every XML file check each and every XML tag is properly close or not.
  2. Specially it appear with images kindly remove images and clean project.
  1. 请检查每个 XML 文件检查每个 XML 标签是否正确关闭。
  2. 特别是它出现在图像中,请删除图像并清理项目。

Hope it will work for you.

希望它对你有用。

回答by Santosh Bangar

After searching and using lots of suggestions i got a solution for this:

在搜索并使用了大量建议后,我得到了一个解决方案:

1)I am using nine patch images in my project and android studio doesn't accept abc.9.png image so rename this name to abc.png

1)我在我的项目中使用了九个补丁图像,而 android studio 不接受 abc.9.png 图像,所以将此名称重命名为 abc.png

2)When i am convert my images to nine patch images one image can't convert properly it shows "Bad Patches" i remove this image and recreate and i solved my problem, this problem is comes when i convert my project eclipse to android studio

2)当我将我的图像转换为九个补丁图像时,一个图像无法正确转换它显示“坏补丁”我删除了这个图像并重新创建并解决了我的问题,当我将我的项目 eclipse 转换为 android studio 时出现了这个问题

3) put this in your gradle aaptOptions.setProperty("cruncherEnabled", false)

3) 把它放在你的 gradle aaptOptions.setProperty("cruncherEnabled", false)

Thanks

谢谢