All com.android.support libraries must use the exact same version specification All com.android.support libraries must use the exact same version specification android android

All com.android.support libraries must use the exact same version specification


You can solve this with one of the following solutions:

Update:

As of Android studio 3.0, it becomes much easier as it now shows a more helpful hint, so we only need to follow this hint.
for example:1]

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.0.2 and com.android.support:customtabs:26.1.0

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

Solution:
Add explicitly the library with the old version but with a new version number.
in my case com.android.support:customtabs:26.1.0 so I need to add:

implementation "com.android.support:customtabs:27.0.2"  

ie: Take the library from the second item, and implement it with the version number from the first.

Note: don't forget to press sync now so gradle can rebuild the dependency graph and see if there are any more conflicts.

Explanation:
you may be confused by the error message as don't use customtabs so how I have a conflict!!
well.. you didn't use it directly but one of your libraries uses an old version of customtabs internally, so you need to ask for it directly.

if you curious to know which of your libraries is responsible for the old version and maybe ask the author to update his lib, Run a Gradle dependency report, see the old answer to know how.

Note this


Old answer:

inspired by CommonsWare answer:

Run a Gradle dependency report to see what your full tree ofdependencies is.

From there, you will see which one of your libraries are asking for a different version of the Android Support libraries.For whatever it is asking for, you can ask for it directly with the25.2.0 version or use Gradle's other conflict resolution approaches to get the same versions.


Update:

As of gradle plugin version: 3.0 compile has been replaced by implementation or api see this answer for the difference.

hence use instead:

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

or for windows cmd:

gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath

and search for the conflicted version.

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.


for AS 3.0 an older.

Run:

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

Example:

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

if someone knows a better way in the new gradle plugin please let me know.


  1. Go to project/.idea/libraries folder on your file system and see which libraries are different.
  2. You will have to manually include these libraries with the same version in your build.gradle file.
  3. Then, sync your project.

E.g.:

compile 'com.android.support:appcompat-v7:25.2.0'// Wrong library version found on 1st pointcompile 'com.android.support:customtabs:25.2.0'


For all cases, not just for these versions or libraries:

Pay attention to the little information window that say something about the error, it says the examples that you have to change and add.

In this case:

Found versions 25.1.1, 24.0.0. Examples include com.android.support:animated-vector-drawable:25.1.1 and com.android.support:mediarouter-v7:24.0.0

Your

com.android.support:animated-vector-drawable:25.1.1

is version 25.1.1, and your

com.android.support:mediarouter-v7:24.0.0

is version 24.0.0, so you have to add the mediarouter with the same version:

com.android.support:mediarouter-v7:25.1.1

And do that for every example that the little information window says, in this case all the libraries that doesn't have the version 25.1.1.

You have to sync the gradle after you fix the indicated library to see the next library and package that you have to change.

IMPORTANT:

If you are not explicitly using one or more specified libraries and it is giving you the error, it means that is being used internally by another library, compile it explicitly anyway.

You also can use another method to see the difference of the versions of all the libraries that you are actually compiling (like run a gradle dependency report or go to your libraries files), the real objetive is compile all the libraries that you are using with the same version.