Android facebook lib冲突,如何排除冲突?
Android facebook lib conflicts, how to exclude conflicting?
官方 facebook sdk 库与 android sdk 冲突,尤其是:
'com.android.support:animated-vector-drawables:27.0.1'
Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "re.tryout123"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile ('com.facebook.android:facebook-android-sdk:4.+') {
//Tryin to exlude the conflicting lib...
exclude group: 'com.android.support', module: 'animated-vector-drawable'
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
}
冲突:
错误文本:
All com.android.support libraries must use the exact sasme version
specification (mixing versions can lead to runtime crashes). Found
versions 27.0.1, 26.0.1. Examples includes
com.android.support:animated-vector-drawable:27.0.1 and com
android.support:design:26.0.1
如果我删除 facebook 导入,冲突就消失了,所以我的问题是如何从 facebook 的库中排除 animated-vector-drawables?
你可以看到我在 gradle 文件中是如何尝试的,但现在已经成功了。
提前致谢。
尝试使用 Facebook SDK 版本 4.28.0
compile 'com.facebook.android:facebook-android-sdk:4.28.0'
尝试删除对 design
:
的依赖
compile 'com.android.support:design:26.0.1'
看看它是否编译,因为它是内部包含的。
我的提议:不要从 facebook sdk 中排除库,但强制 gradle 使用特定的库版本:
configurations.all {
resolutionStrategy.force 'com.android.support:cardview-v7:26.0.1'
resolutionStrategy.force 'com.android.support:customtabs:26.0.1'
}
也删除 exclude group
部分:
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile('com.facebook.android:facebook-android-sdk:4.28.0')
我是如何找到这两个库的? 通过 外部库 在 Android 工作室的项目视图中:
提示:我绝对推荐不要使用+登录依赖项(即使是次要版本)。使用 plus,您无法在签出特定提交时重新创建应用程序状态。
首先在您的应用程序的终端中执行 ./gradlew app:dependencies
然后您将得到
+--- com.android.support:design:26.0.1
| +--- com.android.support:support-v4:26.0.1 -> 27.0.1
| | +--- com.android.support:support-compat:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- android.arch.lifecycle:runtime:1.0.0
| | | +--- android.arch.lifecycle:common:1.0.0
| | | \--- android.arch.core:common:1.0.0
| | +--- com.android.support:support-media-compat:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- com.android.support:support-compat:27.0.1 (*)
| | +--- com.android.support:support-core-utils:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- com.android.support:support-compat:27.0.1 (*)
| | +--- com.android.support:support-core-ui:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- com.android.support:support-compat:27.0.1 (*)
| | \--- com.android.support:support-fragment:27.0.1
| | +--- com.android.support:support-compat:27.0.1 (*)
| | +--- com.android.support:support-core-ui:27.0.1 (*)
| | +--- com.android.support:support-core-utils:27.0.1 (*)
| | \--- com.android.support:support-annotations:27.0.1
| +--- com.android.support:appcompat-v7:26.0.1 -> 27.0.1
| | +--- com.android.support:support-annotations:27.0.1
| | +--- com.android.support:support-core-utils:27.0.1 (*)
| | +--- com.android.support:support-fragment:27.0.1 (*)
| | +--- com.android.support:support-vector-drawable:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- com.android.support:support-compat:27.0.1 (*)
| | \--- com.android.support:animated-vector-drawable:27.0.1
| | +--- com.android.support:support-vector-drawable:27.0.1 (*)
| | \--- com.android.support:support-core-ui:27.0.1 (*)
| +--- com.android.support:recyclerview-v7:26.0.1
| | +--- com.android.support:support-annotations:26.0.1 -> 27.0.1
| | +--- com.android.support:support-compat:26.0.1 -> 27.0.1 (*)
| | \--- com.android.support:support-core-ui:26.0.1 -> 27.0.1 (*)
| \--- com.android.support:transition:26.0.1
| +--- com.android.support:support-annotations:26.0.1 -> 27.0.1
| \--- com.android.support:support-v4:26.0.1 -> 27.0.1 (*)
+--- com.android.support:appcompat-v7:26.0.1 -> 27.0.1 (*)
+--- com.android.support:recyclerview-v7:26.0.1 (*)
+--- com.facebook.android:facebook-android-sdk:4.+ -> 4.29.0
| +--- com.facebook.android:facebook-core:4.29.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
| | +--- com.android.support:support-annotations:27.0.1
| | \--- com.android.support:support-core-utils:27.0.1 (*)
| +--- com.facebook.android:facebook-common:4.29.0
| | +--- com.facebook.android:facebook-core:4.29.0 (*)
| | +--- com.android.support:appcompat-v7:27.0.1 (*)
| | +--- com.android.support:cardview-v7:27.0.1
| | | \--- com.android.support:support-annotations:27.0.1
| | +--- com.android.support:customtabs:27.0.1
| | | +--- com.android.support:support-compat:27.0.1 (*)
| | | \--- com.android.support:support-annotations:27.0.1
| | +--- com.android.support:support-v4:27.0.1 (*)
| | \--- com.google.zxing:core:3.3.0
| +--- com.facebook.android:facebook-login:4.29.0
| | +--- com.facebook.android:facebook-core:4.29.0 (*)
| | \--- com.facebook.android:facebook-common:4.29.0 (*)
| +--- com.facebook.android:facebook-share:4.29.0
| | +--- com.facebook.android:facebook-core:4.29.0 (*)
| | \--- com.facebook.android:facebook-common:4.29.0 (*)
| +--- com.facebook.android:facebook-places:4.29.0
| | \--- com.facebook.android:facebook-core:4.29.0 (*)
| +--- com.facebook.android:facebook-applinks:4.29.0
| | \--- com.facebook.android:facebook-core:4.29.0 (*)
| \--- com.facebook.android:facebook-messenger:4.29.0
| \--- com.facebook.android:facebook-core:4.29.0 (*)
\--- com.crashlytics.sdk.android:crashlytics:2.6.8
+--- com.crashlytics.sdk.android:beta:1.2.5
| \--- io.fabric.sdk.android:fabric:1.3.17
+--- io.fabric.sdk.android:fabric:1.3.17
+--- com.crashlytics.sdk.android:crashlytics-core:2.3.17
| +--- io.fabric.sdk.android:fabric:1.3.17
| \--- com.crashlytics.sdk.android:answers:1.3.13
| \--- io.fabric.sdk.android:fabric:1.3.17
\--- com.crashlytics.sdk.android:answers:1.3.13 (*)
通过com.android.support
搜索可以看到有很多地方使用2版本27.0.1
和26.0.1
。这就是你发出警告的原因。修复它
第一种方式:通过排除 facebook 的 all com.android.support... 27.0.1
让你的应用只使用 26.0.1
com.android.support... 27.0.1
=29=]
compile ('com.facebook.android:facebook-android-sdk:4.+') {
exclude group:'com.android.support', module:'support-annotations'
exclude group:'com.android.support', module:'support-core-utils'
exclude group:'com.android.support', module:'appcompat-v7'
exclude group:'com.android.support', module:'customtabs'
exclude group:'com.android.support', module:'support-v4'
exclude group: 'com.android.support', module:'cardview-v7'
}
Exclude 工作正常但有一个问题:缺少 cardview-v7
和 customtabs
(因为目前没有库提供 cardview-v7
和 customtabs
)。所以需要编译
compile 'com.android.support:cardview-v7:26.0.1'
compile 'com.android.support:customtabs:26.0.1'
第二种方式:让你的应用只使用27.0.1
by
将 compileSdkVersion
从 26 升级到 27
将下面的所有编译从26.0.1
更新为27.0.1
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
您可以通过流程解决类似问题。
希望对你有帮助
官方 facebook sdk 库与 android sdk 冲突,尤其是: 'com.android.support:animated-vector-drawables:27.0.1'
Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "re.tryout123"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile ('com.facebook.android:facebook-android-sdk:4.+') {
//Tryin to exlude the conflicting lib...
exclude group: 'com.android.support', module: 'animated-vector-drawable'
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
}
冲突:
错误文本:
All com.android.support libraries must use the exact sasme version specification (mixing versions can lead to runtime crashes). Found versions 27.0.1, 26.0.1. Examples includes com.android.support:animated-vector-drawable:27.0.1 and com android.support:design:26.0.1
如果我删除 facebook 导入,冲突就消失了,所以我的问题是如何从 facebook 的库中排除 animated-vector-drawables?
你可以看到我在 gradle 文件中是如何尝试的,但现在已经成功了。
提前致谢。
尝试使用 Facebook SDK 版本 4.28.0
compile 'com.facebook.android:facebook-android-sdk:4.28.0'
尝试删除对 design
:
compile 'com.android.support:design:26.0.1'
看看它是否编译,因为它是内部包含的。
我的提议:不要从 facebook sdk 中排除库,但强制 gradle 使用特定的库版本:
configurations.all {
resolutionStrategy.force 'com.android.support:cardview-v7:26.0.1'
resolutionStrategy.force 'com.android.support:customtabs:26.0.1'
}
也删除 exclude group
部分:
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile('com.facebook.android:facebook-android-sdk:4.28.0')
我是如何找到这两个库的? 通过 外部库 在 Android 工作室的项目视图中:
提示:我绝对推荐不要使用+登录依赖项(即使是次要版本)。使用 plus,您无法在签出特定提交时重新创建应用程序状态。
首先在您的应用程序的终端中执行 ./gradlew app:dependencies
然后您将得到
+--- com.android.support:design:26.0.1
| +--- com.android.support:support-v4:26.0.1 -> 27.0.1
| | +--- com.android.support:support-compat:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- android.arch.lifecycle:runtime:1.0.0
| | | +--- android.arch.lifecycle:common:1.0.0
| | | \--- android.arch.core:common:1.0.0
| | +--- com.android.support:support-media-compat:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- com.android.support:support-compat:27.0.1 (*)
| | +--- com.android.support:support-core-utils:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- com.android.support:support-compat:27.0.1 (*)
| | +--- com.android.support:support-core-ui:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- com.android.support:support-compat:27.0.1 (*)
| | \--- com.android.support:support-fragment:27.0.1
| | +--- com.android.support:support-compat:27.0.1 (*)
| | +--- com.android.support:support-core-ui:27.0.1 (*)
| | +--- com.android.support:support-core-utils:27.0.1 (*)
| | \--- com.android.support:support-annotations:27.0.1
| +--- com.android.support:appcompat-v7:26.0.1 -> 27.0.1
| | +--- com.android.support:support-annotations:27.0.1
| | +--- com.android.support:support-core-utils:27.0.1 (*)
| | +--- com.android.support:support-fragment:27.0.1 (*)
| | +--- com.android.support:support-vector-drawable:27.0.1
| | | +--- com.android.support:support-annotations:27.0.1
| | | \--- com.android.support:support-compat:27.0.1 (*)
| | \--- com.android.support:animated-vector-drawable:27.0.1
| | +--- com.android.support:support-vector-drawable:27.0.1 (*)
| | \--- com.android.support:support-core-ui:27.0.1 (*)
| +--- com.android.support:recyclerview-v7:26.0.1
| | +--- com.android.support:support-annotations:26.0.1 -> 27.0.1
| | +--- com.android.support:support-compat:26.0.1 -> 27.0.1 (*)
| | \--- com.android.support:support-core-ui:26.0.1 -> 27.0.1 (*)
| \--- com.android.support:transition:26.0.1
| +--- com.android.support:support-annotations:26.0.1 -> 27.0.1
| \--- com.android.support:support-v4:26.0.1 -> 27.0.1 (*)
+--- com.android.support:appcompat-v7:26.0.1 -> 27.0.1 (*)
+--- com.android.support:recyclerview-v7:26.0.1 (*)
+--- com.facebook.android:facebook-android-sdk:4.+ -> 4.29.0
| +--- com.facebook.android:facebook-core:4.29.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
| | +--- com.android.support:support-annotations:27.0.1
| | \--- com.android.support:support-core-utils:27.0.1 (*)
| +--- com.facebook.android:facebook-common:4.29.0
| | +--- com.facebook.android:facebook-core:4.29.0 (*)
| | +--- com.android.support:appcompat-v7:27.0.1 (*)
| | +--- com.android.support:cardview-v7:27.0.1
| | | \--- com.android.support:support-annotations:27.0.1
| | +--- com.android.support:customtabs:27.0.1
| | | +--- com.android.support:support-compat:27.0.1 (*)
| | | \--- com.android.support:support-annotations:27.0.1
| | +--- com.android.support:support-v4:27.0.1 (*)
| | \--- com.google.zxing:core:3.3.0
| +--- com.facebook.android:facebook-login:4.29.0
| | +--- com.facebook.android:facebook-core:4.29.0 (*)
| | \--- com.facebook.android:facebook-common:4.29.0 (*)
| +--- com.facebook.android:facebook-share:4.29.0
| | +--- com.facebook.android:facebook-core:4.29.0 (*)
| | \--- com.facebook.android:facebook-common:4.29.0 (*)
| +--- com.facebook.android:facebook-places:4.29.0
| | \--- com.facebook.android:facebook-core:4.29.0 (*)
| +--- com.facebook.android:facebook-applinks:4.29.0
| | \--- com.facebook.android:facebook-core:4.29.0 (*)
| \--- com.facebook.android:facebook-messenger:4.29.0
| \--- com.facebook.android:facebook-core:4.29.0 (*)
\--- com.crashlytics.sdk.android:crashlytics:2.6.8
+--- com.crashlytics.sdk.android:beta:1.2.5
| \--- io.fabric.sdk.android:fabric:1.3.17
+--- io.fabric.sdk.android:fabric:1.3.17
+--- com.crashlytics.sdk.android:crashlytics-core:2.3.17
| +--- io.fabric.sdk.android:fabric:1.3.17
| \--- com.crashlytics.sdk.android:answers:1.3.13
| \--- io.fabric.sdk.android:fabric:1.3.17
\--- com.crashlytics.sdk.android:answers:1.3.13 (*)
通过com.android.support
搜索可以看到有很多地方使用2版本27.0.1
和26.0.1
。这就是你发出警告的原因。修复它
第一种方式:通过排除 facebook 的 all com.android.support... 27.0.1
让你的应用只使用 26.0.1
com.android.support... 27.0.1
=29=]
compile ('com.facebook.android:facebook-android-sdk:4.+') {
exclude group:'com.android.support', module:'support-annotations'
exclude group:'com.android.support', module:'support-core-utils'
exclude group:'com.android.support', module:'appcompat-v7'
exclude group:'com.android.support', module:'customtabs'
exclude group:'com.android.support', module:'support-v4'
exclude group: 'com.android.support', module:'cardview-v7'
}
Exclude 工作正常但有一个问题:缺少 cardview-v7
和 customtabs
(因为目前没有库提供 cardview-v7
和 customtabs
)。所以需要编译
compile 'com.android.support:cardview-v7:26.0.1'
compile 'com.android.support:customtabs:26.0.1'
第二种方式:让你的应用只使用27.0.1
by
将
compileSdkVersion
从 26 升级到 27将下面的所有编译从
26.0.1
更新为27.0.1
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
您可以通过流程解决类似问题