添加 facebook sdk 时如何解决此构建错误

How can I resolve this build error when adding facebook sdk

我在 Android studio 中一直遇到 BUILD FAILED 问题,我之前也解决过其他类似的错误,但这一个很难。基本上我所做的是将 quickstart-android-auth 添加到现有的工作 Android 项目中。

一切正常,直到我添加 quickstart-android-auth 文件和独立文件。

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 15 declared in library [com.facebook.android:facebook-android-sdk:4.16.0] D:\AndroidStudioProjects\Nogget\app\build\intermediates\exploded-aar\com.facebook.android\facebook-android-sdk.16.0\AndroidManifest.xml Suggestion: use tools:overrideLibrary="com.facebook" to force usage

这是我的 Build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.2'

    dexOptions {
        dexInProcess = true
    }

    defaultConfig {
        applicationId "com.port.android"
        minSdkVersion 14
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    repositories {
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
        mavenCentral()
    }

    packagingOptions{
        exclude 'META-INF/LICENSE'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.android.support:support-compat:24.2.0'
    compile 'com.google.android.gms:play-services:9.6.0'
    compile 'com.android.support:support-v13:24.2.0'
    compile "com.google.firebase:firebase-messaging:9.0.0"
    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.android.support:design:24.2.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:percent:24.2.0'
    compile 'me.grantland:autofittextview:0.2.+'
    compile 'com.google.firebase:firebase-auth:9.2.1'
    compile 'com.google.firebase:firebase-messaging:9.2.1'
    compile 'com.google.android.gms:play-services-appinvite:9.6.0'
    compile 'com.google.firebase:firebase-analytics:9.2.1'
    compile 'com.google.firebase:firebase-crash:9.6.0'
    compile 'com.google.android.gms:play-services-ads:9.6.0'
    compile 'com.github.bmelnychuk:atv:1.2.+'
    compile 'com.github.johnkil.print:print:1.2.2'
    testCompile 'junit:junit:4.12'
    compile 'com.seatgeek:placesautocomplete:0.2-SNAPSHOT'
    compile 'com.fasterxml.jackson.core:jackson-core:2.7.2'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.2'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
    compile 'com.facebook.android:facebook-android-sdk:4.16.0'
    compile('com.twitter.sdk.android:twitter-core:1.6.6@aar') {
        transitive = true
    }
    compile('com.twitter.sdk.android:twitter:1.13.1@aar') {
        transitive = true;
    }
}
apply plugin: 'com.google.gms.google-services'

如错误所述,您的 minSDK 是 14,但最新的 FacebookSDK 需要 mins SDK 15。增加您的 minSDK 应该可以解决您的问题

将您的 minSdkVersion 更改为 15 而不是 14。
Facebook 库要求 api 15。因此您的项目不能将 minsdkversion 设置为 14...

将 build.gradle 中的 minSdk 设置为 15,因为 facebook 支持从 API 15.