Android Studio:java.exe以非零退出值2结束

时间:2015-10-23 23:30:36

标签: android android-studio gradle android-gradle

Android Studio新手。

我刚刚创建了一个新的空白应用,并添加了一个新的Google云端模块。 添加模块后,我收到错误:

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2

我已经在StackOverflow上阅读了这里的多个答案,所有这些都暗示了gradle依赖的错误,但是我看不到它。这是我的两个gradle文件:

build.gradle(Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.bristow.conor.intellipa"
        minSdkVersion 23
        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.0'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile project(path: ':backend', configuration: 'android-endpoints')
}

build.gradle(模块:后端)

// If you would like more information on the gradle-appengine-plugin please refer to the github page
// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18'
    }
}

repositories {
    jcenter();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
    compile 'com.google.appengine:appengine-endpoints:1.9.18'
    compile 'com.google.appengine:appengine-endpoints-deps:1.9.18'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.googlecode.objectify:objectify:4.0b3'
    compile 'com.ganyo:gcm-server:1.0.2'
}

appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }
    endpoints {
        getClientLibsOnBuild = true
        getDiscoveryDocsOnBuild = true
    }
}

我没有看到任何重复,也没有使用带有似乎解决其他人问题的版本号的'+'。我没有添加/修改或修改项目,但还是添加了模块。在添加模块之前,它可以正确编译。

2 个答案:

答案 0 :(得分:0)

在gradle文件中添加此行

defaultConfig {        
    // Enabling multidex support.
    multiDexEnabled true
}

答案 1 :(得分:-1)

使用compile 'com.google.android.gms:play-services-gcm:8.3.0' 而不是'com.google.android.gms:play-services:8.1.0'