将 Facebook SDK 添加到 Android Studio build.gradle 时出错

Error when adding Facebook SDK to Android Studio build.gradle

我试过手动添加一个模块,并遵循了一些指南来添加 facebook sdk。没有任何效果!目前,我只是想将它添加到我的 build.gradle 文件中,但这也会产生错误。任何帮助都会很棒!还尝试过其他人报告工作的以前的 facebook 版本。

错误:

Execution failed for task ':Selfies:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_05\bin\java.exe'' finished with non-zero exit value 2

一些可能与错误相关的事情:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;

build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 18
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.domelz.pix"
    minSdkVersion 15
    targetSdkVersion 19
}

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

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}
}

repositories {
    mavenCentral()
}

dependencies {
    compile project(':googleplayservices_lib')
    compile files('libs/android-support-v4.jar')
    compile files('libs/commons-io-2.4.jar')
    compile files('libs/Parse-1.4.3.jar')
    compile files('libs/picasso-2.1.1.jar')
    compile files('libs/joda-time-2.8.1.jar')
    compile 'com.facebook.android:facebook-android-sdk:4.6.0'
}

Facebook Android SDK 使用的支持库与您的 SDK 提供的支持库似乎存在冲突!

如果您使用的是最新的 Android Studio,则无需添加支持库 (jar)。

请尝试从您的依赖项中删除该支持库,它应该可以解决您的问题!

祝你好运!