首页 文章

错误:以非零退出值2结束

提问于
浏览
2

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

com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:处理'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java''完成非零退出值2 **

我有2个gradle .

第一个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')}

第二个gradle(模块导入)

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. *),但没有解决 .

谢谢!

2 回答

  • 1

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

    在你的gradle上:

    multiDexEnabled true
    

    要检查你是否有超过65种方法你应该使用proguard功能,或者更简单地使用这个lib来检查有多少方法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

  • 5

    您的 compilesdkversiontargetsdkversion 不同更新您的 Targetsdkversioncompilesdkversion 相同版本

    apply plugin: 'test.test.myapplication'
     android {
      compileSdkVersion 21
      buildToolsVersion "21.1.2"
      defaultConfig {
      applicationId "alo.com.geoapp"
      minSdkVersion 8
      targetSdkVersion 21    //here
      versionCode 1
      versionName "1.0"
     }
    buildTypes {
      release {
        minifyEnabled true
        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')
     }
    

相关问题