进程 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' 以非零退出值 2 结束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34494970/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 22:58:04  来源:igfitidea点击:

Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 2

javaandroidparsingandroid-gradle-pluginfacebook-android-sdk

提问by minimanimo

i've some error with my project. I'm Android beginner. When I try to compile my app I get a following error

我的项目有一些错误。我是安卓初学者。当我尝试编译我的应用程序时,出现以下错误

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 2

错误:任务 ':app:transformClassesWithDexForDebug' 的执行失败。com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_25 \bin\java.exe'' 以非零退出值 2 结束

I'm using Parse SDK for login with Facebook,but in this moment,i've only this code in my app:

我正在使用 Parse SDK 登录 Facebook,但此刻,我的应用程序中只有以下代码:

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // [Optional] Power your app with Local Datastore. For more info, go to
    // https://parse.com/docs/android/guide#local-datastore
    Parse.enableLocalDatastore(this);

    Parse.initialize(this);

my build.gradle is:

我的 build.gradle 是:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.daniele.myapplication"
    minSdkVersion 15
    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.1'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
  }

How can I solve it? First answer of this doesn't work for me: java.exe finished with non-zero exit value 2 when using Facebook SDKMany thanks.

我该如何解决?这个的第一个答案对我不起作用:java.exe 使用 Facebook SDK 时以非零退出值 2 结束非常感谢。

EDIT: I solved it,for now. I deleted 'com.parse:parse-android:1.+' from dependecies and it works. I don't know why,but in the parse's tutorial,it suggest to add all of this dependencies

编辑:我现在解决了。我从依赖项中删除了 'com.parse:parse-android:1.+' 并且它可以工作。我不知道为什么,但在解析的教程中,它建议添加所有这些依赖项

回答by Ashish Tikarye

 defaultConfig {
    applicationId "com.minls.cmn"
    minSdkVersion 11
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

}
**dexOptions {
    javaMaxHeapSize "4g"**
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

put just this line dexOptions { javaMaxHeapSize "4g" }

把这一行 dexOptions { javaMaxHeapSize "4g" }

回答by Mackovich

It seems that you are using Oracle's JDK version 8which is based on Java 8that is not officiallysupported by Android. More details here : https://stackoverflow.com/a/23318269/3535408.

您似乎正在使用Oracle 的 JDK 版本 8,它基于Android未正式支持的Java 8。更多细节在这里:https: //stackoverflow.com/a/23318269/3535408

Some tweaks exist but I do not recommend them. Stick to Java 7 and JDK 7and you are good to go.

存在一些调整,但我不推荐它们。坚持使用Java 7 和 JDK 7,一切顺利。

To change the JDK usage : Go to File > Project Structure > SDK Location > and change the JDK for JDK 7. You can download last version of JDK 7 here : http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

要更改 JDK 用法:转到文件 > 项目结构 > SDK 位置 > 并更改 JDK 7 的 JDK。您可以在此处下载最新版本的 JDK 7:http: //www.oracle.com/technetwork/java/javase/下载/jdk7-downloads-1880260.html

Once I tried to add a Java Library that was compiled using JDK 8 in another IDE (NetBeans). I did not use any Java 8 features such as lambdas in this library but it was enough for Gradle to complain. So back in NetBeans, I changed the settings so that it compiles with JDK 7 and there my problem was solved !

有一次我尝试在另一个 IDE (NetBeans) 中添加使用 JDK 8 编译的 Java 库。我没有在这个库中使用任何 Java 8 特性,比如 lambdas,但这足以让 Gradle 抱怨。所以回到 NetBeans,我更改了设置,以便它使用 JDK 7 进行编译,然后我的问题就解决了!

Hope it helps !

希望能帮助到你 !