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

时间:2016-12-11 09:11:03

标签: java android gradle

请帮助我!

这里有错误说:

  

错误:任务':app:mergeDebugResources'执行失败。

     

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

我的app 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'

我的项目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
}

12 个答案:

答案 0 :(得分:58)

尝试使用模块build.gradle上的代码:

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

这意味着Android工作室不要严格检查PNG。

答案 1 :(得分:13)

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

答案 2 :(得分:10)

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

答案 3 :(得分:4)

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

答案 4 :(得分:2)

我在gimp中添加了一个保存为' filename.9.png' (我认为这足以产生一个9补丁图像)到drawable文件夹。为了解决这个问题,我刚刚在Draw 9-patch工具中打开了图像并移动了其中一个边界 - 我是否将其移回同一位置似乎无关紧要,只是移动边界的行为似乎纠正了这个问题。

答案 5 :(得分:1)

有时我也会收到此错误

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

你可以试试这个。

答案 6 :(得分:1)

我遇到了同样的问题。尽管有多个Rebuild项目,我使用* .png文件并且gradle Build仍然失败。令人惊讶的是,当我将文件名从* .png更改为* .jpg时,它确实有效!

答案 7 :(得分:1)

经过艰苦的努力,我最终解决了这个问题:

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

  1. 请检查每个XML文件,检查每个XML标记是否正确关闭。
  2. 特别是它与图像一起出现,请删除图像并清理项目。
  3. 希望它对你有用。

答案 8 :(得分:1)

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

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

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

时出现了这个问题

3)把它放在你的谜语中 aaptOptions.setProperty(“cruncherEnabled”,false)

由于

答案 9 :(得分:0)

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

答案 10 :(得分:0)

在我的情况下,我在每个屏幕密度可绘制文件夹中都有一个9补丁资源。每个资源中的黑色边框都与彼此不匹配,所以我将它们拉到了角落,所以它们都匹配。

结果如下:

This is the result.

然后它奏效了!

答案 11 :(得分:-3)

也许您放入mipmap的图像问题,删除图像并重试gradle sync汉语就是你放到mipmap中的图片有问题把他删了就好了哎真为我的英语捉急啊〜 〜

相关问题