2017-04-05 217 views
11

我使用facebook-android-sdk:4.20.+com.android.support庫它們與錯誤信息發生衝突:Facebook的Android SDK中依賴衝突

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.2.0, 25.0.0. Examples include com.android.support:animated-vector-drawable:25.2.0 and com.android.support:customtabs:25.0.0 less... (⌘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.) 

以下是我的依賴關係。

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

    compile 'com.android.support:appcompat-v7:25.2.0' 
    compile 'com.android.support:customtabs:25.0.0' 
    compile 'com.android.support:design:25.+' 
    compile 'com.android.support:cardview-v7:25.+' 
    compile 'com.android.support:recyclerview-v7:25.+' 
    compile 'com.fasterxml.jackson.core:jackson-core:2.7.4' 
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.4' 
    compile 'com.fasterxml.jackson.core:jackson-databind:2.7.4' 
    compile 'org.jsoup:jsoup:1.8.3' 
    compile 'com.github.bumptech.glide:glide:3.7.0' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'commons-io:commons-io:2.4' 
    compile 'com.google.android.gms:play-services-analytics:10.0.1' 
    compile 'com.facebook.android:facebook-android-sdk:4.+' 
    testCompile 'junit:junit:4.12' 
} 

在使用運行gradle這個依賴報告:./gradlew -q dependencies app:dependencies --configuration compile,下面是facebook-android-sdk結果。

+--- com.facebook.android:facebook-android-sdk:4.+ -> 4.20.0 
| +--- com.android.support:support-v4:25.0.0 -> 25.2.0 (*) 
| +--- com.android.support:appcompat-v7:25.0.0 -> 25.2.0 (*) 
| +--- com.android.support:cardview-v7:25.0.0 -> 25.2.0 (*) 
| +--- com.android.support:customtabs:25.0.0 
| | +--- com.android.support:support-compat:25.0.0 -> 25.2.0 (*) 
| | \--- com.android.support:support-annotations:25.0.0 -> 25.2.0 
| \--- com.parse.bolts:bolts-android:1.4.0 
|   +--- com.parse.bolts:bolts-tasks:1.4.0 
|   \--- com.parse.bolts:bolts-applinks:1.4.0 
|    \--- com.parse.bolts:bolts-tasks:1.4.0 

是什麼,我必須使用的依賴關係的正確組合?

+0

我覺得這個回答可以幫助你:http://stackoverflow.com/questions/35354359/gradle-error-after-including-facebook-sdk – PedroHidalgo

回答

14

在您的具體情況下,問題是因爲facebook sdk與com.android.support:customtabs:25.0.0有依賴關係,該版本較舊,而您當前版本的支持庫爲25.2.0

正如你在圖cardview-V7的較新版本的依賴看到,程序兼容性-V7和支持-V4已經被使用,所以你可以嘗試添加:

編譯「com.android。支持:customtabs:25.2.0'

,以使customtabs的較新版本是由Facebook的SDK也使用了依賴。

這個答案可能是有幫助的:Gradle error after including facebook sdk

+0

解決我的問題。謝謝。 – pess0a