0

I m new to Android. Every time I include a dependency, I get the below error. I have tried a few possible solutions but nothing seems to work.

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 27.0.2. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:customtabs:27.0.2 less... (Ctrl+F1) Inspection info: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). Issue id: GradleCompatible`

Mateusz Kocz
  • 4,492
  • 1
  • 25
  • 27
TNS
  • 11
  • 3
  • welcome to stackoverflow,please post gradle(module:app) till i can help you – engmms Feb 19 '19 at 19:46
  • 1
    It would be helpful if you listed the solutions you have already tried. That way you won't get the same (not working). – Mateusz Kocz Feb 19 '19 at 19:46
  • Try adding : implementation 'com.android.support:customtabs:28.0.0' – twenk11k Feb 19 '19 at 19:59
  • Possible duplicate of https://stackoverflow.com/questions/42374151/all-com-android-support-libraries-must-use-the-exact-same-version-specification – makata Feb 19 '19 at 20:03

2 Answers2

1

First of all, assuming you're using pre androidx compat, pls make sure all your com.android.support dependencies are sharing exact same version. Here are example dependencies to search for (list is not full of course) :

com.android.support:appcompat-v7
com.android.support:support-annotations
com.android.support:design
com.android.support:cardview-v7
com.android.support:recyclerview-v7
com.android.support:gridlayout-v7
com.android.support:support-v4

Second, if all your compat dependencies are already sharing same version and issue only manifests when you're adding some other known dependency: you can exclude its transitive compat dependencies like this (build.gradle) :

implementation(...) {
    exclude module: 'appcompat-v7'
    exclude module: 'recyclerview-v7'
    exclude module: 'support-v4'
}

or like this:

implementation(...) {
    exclude group: 'com.android.support'
}

Third, if you don't know what kind of dependency is causing troubles - you can find it by reviewing tree generated by ./gradlew app:dependencies

ror
  • 3,295
  • 1
  • 19
  • 27
1

The error was resolved by adding the dependencies specified in the error pop-up. Also the versions of the newly added dependency should be same as appcompat version: In my case the below code line of code resolved the issue: implementation 'com.android.support:support-v4:28.0.0' in the dependencies{}. I hope this helps. Thanks for the help:)

TNS
  • 11
  • 3