Android Studio-Java.exe 以非零退出值 2 结束
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30410140/
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
Android Studio-Java.exe is finished with non-zero exit value 2
提问by adafrwefsefr
When I try to Run my app, I am getting this error:-
当我尝试运行我的应用程序时,出现此错误:-
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
UPDATED:- Here is my Build.gradle(Module:app) file
更新:- 这是我的 Build.gradle(Module:app) 文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "navigationdrawer.tutecentral.com.navigationdrawer"
minSdkVersion 15
targetSdkVersion 22
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'
}
What does that means?
那是什么意思?
采纳答案by cdwheatley
This happened for me when I was refactoring some class files to a library project and I had a duplicate name of a class file. So, double check that you do not have any duplicate names. This also appears to be a duplicate of the question here: android project: process finished with non-zero exit value 2
当我将一些类文件重构为一个库项目并且我有一个类文件的重复名称时,这发生在我身上。因此,请仔细检查您没有任何重复的名称。这似乎也是这里问题的重复:android project: process finished with non-zero exit value 2
回答by vovahost
I got this error when I used the beta version of gradle to test Vector Asset. This error perssisted even after I switched back to stable Gradle version 1.3.0.
The error was fixed after I used Build > Clean project
当我使用 gradle 的 beta 版本来测试 Vector Asset 时,我收到了这个错误。即使在我切换回稳定的 Gradle 版本 1.3.0 之后,这个错误仍然存在。
使用Build > Clean 项目后,错误已修复
回答by Bajirao Shinde
Just add below line in your app Gradle dependencies
只需在您的应用程序 Gradle 依赖项中添加以下行
compile 'com.android.support:multidex:1.0.0'
and then below line in defaultConfig
然后在 defaultConfig 中的行下方
multiDexEnabled true
回答by johnlp
Encountered same problem today. I fixed this problem by closing other applications to release more memory to finish build process.
今天遇到同样的问题。我通过关闭其他应用程序以释放更多内存来完成构建过程来解决这个问题。
When getting this error:
收到此错误时:
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
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' 完成了非零退出值 2
Use process explorer to find out the command line parameter of java.exe, then run complete command in CMD window to see what the error message is. Mine contains "HeapDumpOnOutOfMemoryError", So I close other applications to release more memory, then problem fixed.
使用进程资源管理器找出java.exe的命令行参数,然后在CMD窗口中运行完整命令查看错误信息。我的包含“HeapDumpOnOutOfMemoryError”,所以我关闭其他应用程序以释放更多内存,然后问题解决。
回答by UmAnusorn
Try
尝试
Build > Clean project
构建 > 清理项目
If it not working try to remove
如果它不起作用尝试删除
compile fileTree(dir: 'libs', include: ['*.jar'])
then add lib separeately e.g.
然后分别添加 lib 例如
compile files('libs/jncryptor-1.1.0.jar')
回答by rajlaxmi_jagdale
Just do this Build > Clean project
只需执行此 Build > Clean 项目
It works
有用
回答by Mkurbanov
Edit gradle.properties file. change this line:
编辑 gradle.properties 文件。改变这一行:
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
to:
到:
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8