使用 Facebook SDK 时,java.exe 以非零退出值 2 结束

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

java.exe finished with non-zero exit value 2 when using Facebook SDK

javaandroidgradleandroid-gradle-pluginfacebook-android-sdk

提问by Micha? K

When I try to compile my app I get a following 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_60\bin\java.exe'' finished with non-zero exit value 2

If I get rid of Facebook Android SDK it compiles without a problem.

如果我摆脱了 Facebook Android SDK,它可以毫无问题地编译。

My build.gradle:

我的 build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21 //tried 19 and 22 changing targetSdkVersion and buildToolsVersion accordingly
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "..."
        minSdkVersion 15
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }

...

}

dependencies {
    ...
    compile 'com.facebook.android:facebook-android-sdk:3.23.1' //tried older versions as well
}

采纳答案by Pawel Cala

First of all you should try to list your dependencies with gradle :MODULE:dependenciesCheck if there are libraries conflicts ( same library but different version ). In this case i supose you should exclude support library module from Facebook SDK.

首先,您应该尝试使用gradle :MODULE:dependencies检查是否存在库冲突(相同的库但不同的版本)列出您的依赖项。在这种情况下,我认为您应该从 Facebook SDK 中排除支持库模块。

compile ('com.facebook.android:facebook-android-sdk:3.23.1'){
        exclude group: 'com.google.android', module: 'support-v4'
    }

回答by Andrew

While using Facebook SDK project library, Pawel's solution worked for me.

在使用 Facebook SDK 项目库时,Pawel 的解决方案对我有用。

However it stopped working after I had migrated to Gradle dependency 'com.facebook.android:facebook-android-sdk:4.1.1'. Tried to rebuild/reopen project but nothing helped.

但是,在我迁移到 Gradle 依赖项后它停止工作'com.facebook.android:facebook-android-sdk:4.1.1'。试图重建/重新打开项目,但没有任何帮助。

This worked for me:

这对我有用:

compile ('com.facebook.android:facebook-android-sdk:4.1.1') {
    exclude module: 'support-v4'
}