首页 > 解决方案 > 添加 facebook 依赖 gradle 错误

问题描述

我添加了以下依赖项,login with facebook然后错误可以显示给我。

implementation 'com.facebook.android:facebook-login:[4,5)'

下面的错误告诉我:

所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 27.1.1、27.0.2。示例包括 com.android.support:animated-vector-drawable:27.1.1 和 com.android.support:customtabs:27.0.2 less... (Ctrl+F1) 有一些库的组合,或者工具和库,不兼容或可能导致错误。一种这样的不兼容性是使用不是最新版本的 Android 支持库版本(或者特别是低于您的 targetSdkVersion 的版本)进行编译。

Gradle.build(应用程序):

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:support-v4:27.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.+'
    implementation 'com.android.support:recyclerview-v7:27.1.+'

    implementation 'com.github.bumptech.glide:glide:4.3.1'

    //Volley
    implementation 'com.android.volley:volley:1.0.0'

    //facebook
    implementation 'com.facebook.android:facebook-login:[4,5)'

    implementation 'de.hdodenhof:circleimageview:2.2.0'

    implementation 'com.intuit.ssp:ssp-android:1.0.5'
    implementation 'com.intuit.sdp:sdp-android:1.0.5'

    implementation 'com.ramotion.foldingcell:folding-cell:1.2.2'

    implementation 'com.google.android.gms:play-services-maps:15.0.1'


    implementation project(':revealfab')
}

标签: androidbuild.gradle

解决方案


由于错误明确提到混合 lib 版本不是一个好主意(混合版本会导致运行时崩溃),所以不要那样做。在这里你使用7:27.1.1and 7:27.1.+。因此,为所有库保持相同的版本。

代替:

implementation 'com.facebook.android:facebook-login:[4,5)' // this is wrong
implementation 'com.android.support:cardview-v7:27.1.+'
implementation 'com.android.support:recyclerview-v7:27.1.+'

利用:

implementation 'com.facebook.android:facebook-login:4.35.0' //latest version and correct correct way
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'

推荐阅读