我正在尝试将 Facebook api 包含到我的 android 项目中。在将 Facebook sdk 依赖项添加到 gradle 之前,一切正常。我尝试了许多解决方案,但它们不起作用。添加依赖项后,collapsibleToolbar 布局无法膨胀,它会给出一个 inflateException。
android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class android.support.design.widget.CollapsingToolbarLayout
在阅读不同的解决方案时,我注意到依赖项存在一些问题,因此我生成了 gradle 依赖关系图,如下所示
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.myapplication.sample"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.0.+'
//Picasso
compile 'com.squareup.picasso:picasso:2.5.2'
//Volley
compile 'com.android.volley:volley:1.0.0'
compile project(path: ':volley')
//twitter
compile('com.twitter.sdk.android:twitter:2.3.1@aar') {
transitive = true;
}
//facebook
compile ('com.facebook.android:facebook-android-sdk:[4,5)'){
exclude module: 'support:appcompat-v7'
}
}
以下是依赖图:
+--- com.android.support:appcompat-v7:23.4.0 -> 25.0.0
| +--- com.android.support:support-v4:25.0.0
| | +--- com.android.support:support-compat:25.0.0
| | | \--- com.android.support:support-annotations:25.0.0
| | +--- com.android.support:support-media-compat:25.0.0
| | | \--- com.android.support:support-compat:25.0.0 (*)
| | +--- com.android.support:support-core-utils:25.0.0
| | | \--- com.android.support:support-compat:25.0.0 (*)
| | +--- com.android.support:support-core-ui:25.0.0
| | | \--- com.android.support:support-compat:25.0.0 (*)
| | \--- com.android.support:support-fragment:25.0.0
| | +--- com.android.support:support-compat:25.0.0 (*)
| | +--- com.android.support:support-media-compat:25.0.0 (*)
| | +--- com.android.support:support-core-ui:25.0.0 (*)
| | \--- com.android.support:support-core-utils:25.0.0 (*)
| +--- com.android.support:support-vector-drawable:25.0.0
| | \--- com.android.support:support-compat:25.0.0 (*)
| \--- com.android.support:animated-vector-drawable:25.0.0
| \--- com.android.support:support-vector-drawable:25.0.0 (*)
+--- com.android.support:cardview-v7:23.0.+ -> 25.0.0
| \--- com.android.support:support-annotations:25.0.0
+--- com.android.support:design:23.4.0
| +--- com.android.support:recyclerview-v7:23.4.0
| | +--- com.android.support:support-annotations:23.4.0 -> 25.0.0
| | \--- com.android.support:support-v4:23.4.0 -> 25.0.0 (*)
| +--- com.android.support:appcompat-v7:23.4.0 -> 25.0.0 (*)
| \--- com.android.support:support-v4:23.4.0 -> 25.0.0 (*)
+--- com.android.support:recyclerview-v7:23.0.+ -> 23.4.0 (*)
+--- com.squareup.picasso:picasso:2.5.2
+--- com.android.volley:volley:1.0.0
+--- project :volley
+--- com.twitter.sdk.android:twitter:2.3.1
| +--- com.twitter.sdk.android:tweet-composer:2.3.1
| | +--- com.twitter:twitter-text:1.13.0
| | +--- io.fabric.sdk.android:fabric:1.3.14
| | +--- com.twitter.sdk.android:twitter-core:2.3.0
| | | +--- com.google.code.gson:gson:2.6.1
| | | +--- com.squareup.retrofit2:converter-gson:2.0.2
| | | | +--- com.squareup.retrofit2:retrofit:2.0.2
| | | | | \--- com.squareup.okhttp3:okhttp:3.2.0
| | | | | \--- com.squareup.okio:okio:1.6.0
| | | | \--- com.google.code.gson:gson:2.6.1
| | | +--- com.squareup.okhttp3:okhttp:3.2.0 (*)
| | | +--- io.fabric.sdk.android:fabric:1.3.14
| | | \--- com.squareup.retrofit2:retrofit:2.0.2 (*)
| | \--- com.squareup.picasso:picasso:2.5.2
| +--- com.twitter.sdk.android:tweet-ui:2.3.1
| | +--- io.fabric.sdk.android:fabric:1.3.14
| | +--- com.twitter.sdk.android:twitter-core:2.3.0 (*)
| | +--- com.android.support:support-v4:23.1.1 -> 25.0.0 (*)
| | \--- com.squareup.picasso:picasso:2.5.2
| +--- io.fabric.sdk.android:fabric:1.3.14
| \--- com.twitter.sdk.android:twitter-core:2.3.0 (*)
\--- com.facebook.android:facebook-android-sdk:[4,5) -> 4.19.0
+--- com.android.support:appcompat-v7:25.0.0 (*)
+--- com.android.support:cardview-v7:25.0.0 (*)
+--- com.android.support:customtabs:25.0.0
| +--- com.android.support:support-compat:25.0.0 (*)
| \--- com.android.support:support-annotations:25.0.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
我试图从 facebook sdk 中排除 support:v4 和 support:appcompat-v7。我该如何解决这个问题?