【问题标题】:Execution failed for task ':app:dexDebug' non-zero exit value 2任务 ':app:dexDebug' 非零退出值 2 执行失败
【发布时间】:2016-04-24 10:25:36
【问题描述】:

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

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/local/java/jdk1.8.0_73/bin/java'' 用非完成零退出值 2
这个错误出现在我所有的项目中

build.gradle 文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.mukesh.airpollution"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

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

dependencies {
    compile group: 'cz.msebera.android', name: 'httpclient', version: '4.4.1.1'
}

dependencies {
    compile 'com.android.support:recyclerview-v7:23.1.1'
}

dependencies {
    compile 'com.loopj.android:android-async-http:1.4.4'
}

dependencies {
    compile 'com.google.code.gson:gson:2.2.4'
}

dependencies {
    compile group: 'cz.msebera.android', name: 'httpclient', version: '4.4.1.1'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.google.maps.android:android-maps-utils:0.4+'
}

【问题讨论】:

  • 发布您的 build.gradle 文件。
  • 这可能是一个多索引问题。尝试应用多索引支持。见stackoverflow.com/questions/32407985/…
  • @MonishKamble 添加了 gradle 文件
  • @DevrimTuncer 这并不总是一个解决方案...@Martin,请参阅this post
  • 你真的应该压缩所有dependencies 部分......你只需要一个单个一个。

标签: android android-gradle-plugin


【解决方案1】:

尝试按如下方式压缩您的 build.gradle(删除 httpclient 的重复条目):

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.mukesh.airpollution"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

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

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.maps.android:android-maps-utils:0.4+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.loopj.android:android-async-http:1.4.4'
compile group: 'cz.msebera.android', name: 'httpclient', version: '4.4.1.1'
}

告诉我它是否有效?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-23
    • 1970-01-01
    • 1970-01-01
    • 2016-05-31
    • 2015-10-17
    • 2015-08-12
    相关资源
    最近更新 更多