android - 添加 Facebook Android SDK 依赖项后出现此错误

标签 android sdk dependencies build.gradle facebook-sdk-4.0

添加Android Facebook SDK依赖后

compile 'com.facebook.android:facebook-android-sdk:4.21.0'

我遇到了错误

compile 'com.android.support:appcompat-v7:25.3.1'

但项目运行良好。

enter image description here

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.3.1, 25.0.0. Examples include com.android.support:animated-vector-drawable:25.3.1 and com.android.support:cardview-v7:25.0.0 less... (Ctrl+F1)

There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

Build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    repositories {
        mavenCentral()
    }

    defaultConfig {
        applicationId "sujeet.raj.com"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'

    testCompile 'junit:junit:4.12'

    compile 'com.facebook.android:facebook-android-sdk:4.21.0'
}

最佳答案

这个问题是由于下载了不同版本的依赖文件导致的。

明确将其也放入 gradle 文件中并再次同步。

compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'

在这个目录下可以找到正在下载的库

Project Files/Your project/.idea/libraries

关于android - 添加 Facebook Android SDK 依赖项后出现此错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43256103/

相关文章:

ipad - 我们如何打印包含 uiimage 的 ipad View 和多行的 uitableview

spring - 什么是 Spring Framework 中的依赖注入(inject)和控制反转?

html - 如何快速填充 Rails 中的 *data inter-dependent* <select> 下拉菜单?

android - 在按钮之间放置 ScrollView

android - 我怎样才能得到 Android 的 Paypal jar 文件?

iphone - 翻页示例代码

Eclipse 与其他项目的构建路径

java - Android/java 时间格式?

安卓分贝计

android - 几个小时后融合位置停止发送更新