Android facebook lib conflicts, how to exclude conflicting?
Asked Answered
S

4

7

Official facebook sdk lib conflicts with android sdk, especially with: '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;
    }
}

Conflict:

enter image description here

Error text:

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

If I remove the facebook import, the conflict is gone, so my question is how can I exclude the animated-vector-drawables from facebook's lib?

You can see how I have tried in the gradle file but now success yet.

Thanks in advance.

Shipowner answered 9/1, 2018 at 11:30 Comment(0)
M
13

First execute ./gradlew app:dependencies in the Terminal for your app then you will get

+--- 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 (*)

Search by com.android.support you can see that there is many place use it with 2 version 27.0.1 and 26.0.1. This is the reason why you have warning. To fix it

First way: Make you app only use 26.0.1 by exclude all com.android.support... 27.0.1 of facebook like

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 work well but there is a problem: cardview-v7 and customtabs is missing (because currently no library provide cardview-v7 and customtabs). So you need to compile

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

Second way: Make you app only use 27.0.1 by

  • Upgrade compileSdkVersion from 26 to 27

  • Update all compile below from 26.0.1 to 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'

You can the flow to solve the similar problem here. Hope it help

Miscegenation answered 15/1, 2018 at 2:27 Comment(0)
C
1

My proposition: do not exclude libs from facebook sdk but force gradle to use particular lib version:

configurations.all {
resolutionStrategy.force 'com.android.support:cardview-v7:26.0.1'
resolutionStrategy.force 'com.android.support:customtabs:26.0.1'

}

Remove also exclude group part:

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

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

How i have found these two libraries? Via External Libraries in Project view in Android studio: enter image description here

Tip: I definitely recommend not to use + sign in dependencies (even for minor versions). With plus you are not able to recreate state of application while checkout particular commit.

Corniculate answered 12/1, 2018 at 20:33 Comment(0)
S
0

Try to use Facebook SDK version 4.28.0

 compile 'com.facebook.android:facebook-android-sdk:4.28.0'
Standoffish answered 9/1, 2018 at 13:34 Comment(2)
Why would I? I need to exlude the conflicting lib, how I do that?Shipowner
@adam-varhegyi This is just a temporary workaround. I have faced with this bug and reported to Facebook.Diachronic
B
0

Try removing dependency the for design:

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

and see if it compiles, because it is internally included.

Battledore answered 10/1, 2018 at 7:38 Comment(1)
I use appcompat too, and that one is also conflicts with Facebook SDK. Can I just exlude the conflicting package from Facebook SDK ?Shipowner

© 2022 - 2024 — McMap. All rights reserved.