Gradle构建错误:Android java.exe以非零退出值1结束

时间:2015-04-30 00:16:26

标签: java android

已在以下所有链接上试用过该解决方案: Gradle Build Errors

Android Studio Gradle Error - preDexDebug

Android java.exe finished with non-zero exit value 1

finished with non zero exit value

Execution failed for task: ':app:preDexDebug'

http://fqa.io/questions/29045129/android-java-exe-finished-with-non-zero-exit-value-1

http://fqa.io/questions/28933701/android-studio-unable-to-resolve-error-apppredexdebug

错误仍然存​​在。任何帮助将真正受到赞赏。谢谢!

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72211Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42211Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:preDexDebug FAILED
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1

当我使用--debug选项运行时,它会将错误显示为:

Error:05:43:59.724 [ERROR] [org.gradle.BuildExceptionReporter] 
05:43:59.725 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
05:43:59.726 [ERROR] [org.gradle.BuildExceptionReporter] 
05:43:59.727 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
05:43:59.728 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:preDexDebug'.
05:43:59.729 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1
05:43:59.732 [ERROR] [org.gradle.BuildExceptionReporter] 
05:43:59.733 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
05:43:59.734 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. 

build.gradle(Project:MyApplication)的内容

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

build.gradle的内容(模块:app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.user.myapplication"
        minSdkVersion 8
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
}

5 个答案:

答案 0 :(得分:6)

我突然遇到了同样的错误,我意识到这是因为新的Google Play服务库。

我改变了这一行

compile 'com.google.android.gms:play-services:7.3.0'

回到

compile 'com.google.android.gms:play-services:7.0.0'

我可以再次运行该应用。一旦我更新到7.3.0,问题就会重新出现(每一次)。

我正在使用Android Studio 1.2,gradle插件1.2.2,compileSdkVersion 22,buildToolsVersion 22.0.1。

答案 1 :(得分:1)

试试你说的是什么标记但你保持 com.android.tools.build:gradle:1.1.0

答案 2 :(得分:0)

尝试确保在构建Android应用时保持最新状态,尤其是build tools

热门build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.2' // <-- was 1.1.0

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

应用程序/ build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22 // <-- was 21
    buildToolsVersion "22.0.1" // <-- was 21.1.2

    defaultConfig {
        applicationId "com.example.user.myapplication"
        minSdkVersion 9
        targetSdkVersion 22 // <-- was 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:22.1.1'
}

答案 3 :(得分:0)

我有同样的错误。我正在使用不同的SDK构建工具构建使用此错误的库。我只需右键点击该库,对于我的案例&#34;谷歌地图&#34;,点击&#34;打开模块设置&#34;,然后更改Compile SDK版本以及构建工具版本我用于我的app目录的同一版本

答案 4 :(得分:-1)

就我而言,我通过删除incremental truedexOptions)中的app/build.gradle解决了这个问题。

incrementalmultidex是不可能的。