10

After adding Android Facebook SDK dependencies

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

I'm getting error in

compile 'com.android.support:appcompat-v7:25.3.1'

But Project is running fine.

enter image description here

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

Build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"

    repositories {
        mavenCentral()
    }

    defaultConfig {
        applicationId "sujeet.raj.com"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

    testCompile 'junit:junit:4.12'

    compile 'com.facebook.android:facebook-android-sdk:4.21.0'
}
omerfarukdogan
  • 839
  • 9
  • 26
Sujeet Kumar
  • 1,822
  • 22
  • 25

4 Answers4

7

This problem occurs due to different version of dependency files get downloaded.

Explicitly put this as well in gradle file and sync again.

compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'

Under this directory you can find these libraries getting downloaded

Project Files/Your project/.idea/libraries
Sreehari
  • 5,621
  • 2
  • 25
  • 59
  • 4
    With `facebook-android-sdk:4.24.0` I has to use `customtabs` in place of `animated-vector-drawable` – wrozwad Jul 04 '17 at 07:45
  • @sosite how did you figure this out? If the Facebook SDK internally tells it to download an older version, how does manually listing what version of the support library component to download fix that? – Flyview Oct 27 '17 at 22:18
  • I used the latest packages...and these steps worked for me – anoop4real Oct 30 '18 at 11:05
3

Don't ask me why but this solved it for me:

android {
/.../
    configurations.all {
        resolutionStrategy.force 'com.android.support:cardview-v7:27.1.0'
        resolutionStrategy.force 'com.android.support:animated-verctor-drawable:27.1.0'
        resolutionStrategy.force 'com.android.support:customtabs:27.1.0'
        resolutionStrategy.force 'com.google.android.gms:play-services-base:12.0.1'
        resolutionStrategy.force 'com.google.android.gms:play-services-auth:12.0.1'
    }
}
hiddeneyes02
  • 2,562
  • 1
  • 31
  • 58
2

You can solve this with one of the following solutions: original here

Run a Gradle dependency report to see what your full tree of dependencies is. From there, you will see which one of your libraries is asking for a different version of the Android Support libraries. For whatever it is asking for, you can ask for it directly with the 25.2.0 version, or use Gradle's other conflict resolution approaches to arrange to get the same version.

Run:

./gradlew -q dependencies <module-name>:dependencies --configuration compile

Example:

./gradlew -q dependencies app:dependencies --configuration compile

For me, the error disappeared after removing com.google.android.gms:play-services:10.2.0

And only include com.google.android.gms:play-services-location:10.2.0 and com.google.android.gms:play-services-maps:10.2.0 as they are the only two play services that I use.

I think the gms:play-services depend on some old components of the support library, so we need to add them explicitly ourselves.

Community
  • 1
  • 1
AwaisMajeed
  • 2,254
  • 2
  • 10
  • 25
  • As a shortcut, you can also see here - https://www.versioneye.com/java/com.facebook.android:facebook-android-sdk/4.21.0 - the dependencies that the facebook SDK has. (For other versions of the SDK, try replacing the `4.21.0` part of that URL.) – ban-geoengineering Nov 20 '17 at 19:43
0

Maybe I am too late for this, but well, trying to be helpful here... this is how I solve it.

open

project/your project/.idea/libraries

then head to facebook sdk and you can see this

library name="facebook-android-sdk-4.22.1"

use the number "4.22.1" into the one in build.gradle

this is how I do it, I am too a beginner myself.

yuzuriha
  • 465
  • 1
  • 8
  • 18