Gradle 构建错误:Android java.exe 以非零退出值 1 完成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29956850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gradle build error:Android java.exe finished with non-zero exit value 1
提问by Vikas Viki
Have tried out the solution on all the following links: Gradle Build Errors
在以下所有链接上尝试了解决方案: Gradle Build Errors
Android Studio Gradle Error - preDexDebug
Android Studio Gradle 错误 - 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/29045129/android-java-exe-finished-with-non-zero-exit-value-1
http://fqa.io/questions/28933701/android-studio-unable-to-resolve-error-apppredexdebug
http://fqa.io/questions/28933701/android-studio-unable-to-resolve-error-apppredexdebug
The error still remains. Any help will truly be appreciated. Thanks!
错误仍然存在。任何帮助将不胜感激。谢谢!
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
and when i run with --debug option it displays the error as:
当我使用 --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.
And the contents of build.gradle(Project:MyApplication)
以及 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()
}
}
Contents of build.gradle(Module:app):
build.gradle(Module: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'
}
回答by EyesClear
I suddenly got the same error and I realized it was happening because of the new Google Play Services library.
我突然遇到了同样的错误,我意识到这是由于新的 Google Play 服务库而发生的。
I changed this line
我改变了这条线
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.google.android.gms:play-services:7.3.0'
back to
回到
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
and I can run the app again. As soon as I update to 7.3.0, the problem reappears (every single time).
我可以再次运行该应用程序。一旦我更新到 7.3.0,问题就会再次出现(每次)。
I'm using Android Studio 1.2, gradle plugin 1.2.2, compileSdkVersion 22, buildToolsVersion 22.0.1.
我使用的是 Android Studio 1.2,gradle 插件 1.2.2,compileSdkVersion 22,buildToolsVersion 22.0.1。
回答by Back Packer
Try what mark did you say but you keep com.android.tools.build:gradle:1.1.0
试试你说的什么标记,但你保留了com.android.tools.build:gradle:1.1.0
回答by Red M
I had the same error. I was building the library that was giving me this error with a different SDK build tool. All I had to is right click on that library, for my case "google maps", click on "open module settings", and change the Compile SDK version as well as the build tools version to the same version I'm using for my app directory
我有同样的错误。我正在使用不同的 SDK 构建工具构建给我这个错误的库。我所要做的就是右键单击该库,对于我的案例“谷歌地图”,单击“打开模块设置”,然后将编译 SDK 版本以及构建工具版本更改为我正在使用的相同版本应用目录
回答by Jared Burrows
Try to make sure you keep everything up to date, especially the build tools
when building android apps.
尽量确保所有内容都是最新的,尤其是build tools
在构建 android 应用程序时。
Top build.gradle
:
顶部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()
}
}
app/build.gradle
:
应用程序/ 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'
}
回答by Math2T
For my part, i solved this issue by remove incremental true
in dexOptions
(app/build.gradle
).
就我而言,我解决了这个问题,通过删除incremental true
在dexOptions
(app/build.gradle
)。
incremental
and multidex
is not possible.
incremental
并且multidex
是不可能的。