Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

After updating to android studio 2.3 I got this error message. I know it's just a hint as the app run normally but it's really strange.

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). 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

enter image description here

my gradle:

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'     })     testCompile 'junit:junit:4.12'      compile 'com.android.support:appcompat-v7:25.1.1'     compile 'com.android.support:support-v4:25.1.1'     compile 'com.android.support:design:25.1.1'     compile 'com.android.support:recyclerview-v7:25.1.1'     compile 'com.android.support:cardview-v7:25.1.1'     compile 'com.google.android.gms:play-services-maps:10.2.0'     compile 'com.google.android.gms:play-services:10.2.0'      compile 'io.reactivex.rxjava2:rxjava:2.0.1'     compile 'io.reactivex.rxjava2:rxandroid:2.0.1'     compile 'com.jakewharton:butterknife:8.4.0'     annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'     compile 'com.blankj:utilcode:1.3.6'     compile 'com.orhanobut:logger:1.15'     compile 'com.facebook.stetho:stetho:1.4.2'      provided 'com.google.auto.value:auto-value:1.2'     annotationProcessor 'com.google.auto.value:auto-value:1.2'     annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'      compile 'com.mikepenz:iconics-core:2.8.2@aar'     compile('com.mikepenz:materialdrawer:5.8.1@aar') { transitive = true }     compile 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'     compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'     compile 'com.github.GrenderG:Toasty:1.1.1'     compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.8.0'     compile 'com.github.MAXDeliveryNG:slideview:1.0.0'      compile 'com.facebook.fresco:fresco:1.0.1'     compile 'com.github.bumptech.glide:glide:3.7.0'      compile 'com.google.maps.android:android-maps-utils:0.4.4'     compile 'com.github.jd-alexander:library:1.1.0' } 
like image 520
humazed Avatar asked Feb 21 '17 17:02

humazed


People also ask

What are support libraries in Android?

The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Each Support Library is backward-compatible to a specific Android API level.

Should I use Android support libraries?

Originally a single binary library for apps, the Android Support Library has evolved into a suite of libraries for app development. Many of these libraries are now a strongly recommended, if not essential, part of app development.

What is Android Design Support Library?

The Design Support library adds support for various material design components and patterns for app developers to build upon, such as navigation drawers, floating action buttons (FAB), snackbars, and tabs. The Gradle build script dependency identifier for this library is as follows: com. android.


1 Answers

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 of dependencies 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 the 25.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.

like image 93
humazed Avatar answered Oct 19 '22 08:10

humazed