Android facebook lib冲突,如何排除冲突?

时间:2018-01-09 11:30:26

标签: android facebook android-gradle android-facebook

官方facebook sdk lib与android sdk冲突,特别是: 的 'com.android.support:animated-vector-drawables:27.0.1'

摇篮:

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;
    }
}

冲突:

enter image description here

错误文字:

  

所有com.android.support库都必须使用确切的sasme版本   规范(混合版本可能导致运行时崩溃)。发现   版本27.0.1,26.0.1。例子包括   com.android.support:animated-vector-drawable:27.0.1和com   android.support:design:26.0.1

如果我删除了facebook导入,冲突就消失了,所以我的问题是如何从facebook的lib中排除动画矢量抽象?

你可以看到我在gradle文件中的尝试但现在已经成功了。

提前致谢。

4 个答案:

答案 0 :(得分:11)

首先在您的应用终端中执行./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.126.0.1。这就是你有警告的原因。解决它

第一种方式:让你的应用仅使用26.0.1排除所有 com.android.support... 27.0.1的facebook

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'
}

排除良好工作但出现问题:cardview-v7customtabs丢失(因为目前没有图书馆提供cardview-v7customtabs)。所以你需要编译

compile 'com.android.support:cardview-v7:26.0.1'
compile 'com.android.support:customtabs:26.0.1'

第二种方式:让您的应用仅使用{/ 1}}

  • 27.0.1从26升级到27

  • 将以下所有编译从compileSdkVersion更新为26.0.1

27.0.1

您可以通过流程解决类似问题here。 希望有所帮助

答案 1 :(得分:1)

我的主张:不要从facebook sdk中排除libs,但强制gradle使用特定的lib版本:

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')

来源http://www.vogella.com/tutorials/Gradle/article.html#forcing-a-specific-version-of-a-transitive-dependency

我如何在Android工作室的项目视图中找到这两个库?通过外部库enter image description here

提示:我绝对建议 使用+登录依赖项(即使是次要版本)。使用plus,您无法在checkout特定提交时重新创建应用程序状态。

答案 2 :(得分:0)

尝试使用Facebook SDK版本4.28.0

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

答案 3 :(得分:0)

尝试删除design的依赖关系:

compile 'com.android.support:design:26.0.1'

并查看它是否编译,因为它是内部包含的。