错误:以非零退出值2完成

错误:以非零退出值2完成

问题描述:

我在我的应用程序中导入了一个模块.当我尝试运行它时,控制台显示此错误:**错误:任务:app:dexDebug"执行失败.

i've imported a module in my application. When i try to run it, console show me this error: **Error:Execution failed for task ':app:dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command'/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' 以非零退出值 2** 结束

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2**

我有 2 个 gradle.

I've 2 gradle.

第一级(我的申请)

apply plugin: 'test.test.myapplication'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
    applicationId "alo.com.geoapp"
    minSdkVersion 8
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
}

}dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/gson-2.2.2.jar')
compile project(':sdktools')}

2nd gradle(导入模块)

2nd gradle (module imported)

apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
    minSdkVersion 8
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
    }
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/SKMaps.jar')
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.guava:guava:18.0'
compile 'joda-time:joda-time:2.4'}

我已经尝试更新我的 jdk(从 7.* 到 8.*),但没有解决.

i've already tried to update my jdk (from 7.* to 8.*), but not resolve.

谢谢!

如果你有超过 65k 的方法,你应该使用 multidex (http://developer.android.com/tools/building/multidex.html).

If you have more than 65k methods you should use multidex (http://developer.android.com/tools/building/multidex.html).

在你的 gradle 上:

on your gradle:

multiDexEnabled true

要检查是否有超过 65 个方法,您应该使用 proguard 功能,或者更简单地使用这个库来检查有多少方法

To check if you have more than 65 methods you should use proguard feature, or more simply use this lib just to check how many methods https://github.com/KeepSafe/dexcount-gradle-plugin?utm_source=Android+Weekly&utm_campaign=553bcbfc02-Android_Weekly_174&utm_medium=email&utm_term=0_4eb677ad19-553bcbfc02-337295057