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

To elaborate on the accepted answer, proper dependency resolution for the support library case is as follows:

Don't just add transitive dependencies as direct dependencies to force their versions; this is semantically the wrong thing to do (if you ever remove the dependency that brought in the transitive dependency, you now have a leftover dependency you're not actually using).

Do the following:

In your root build.gradle, you should already have

ext {
    supportlib_version = '27.1.1'
    ...
}

and be using this property in your e.g. app/build.gradle like

dependencies {
    implementation "com.android.support:appcompat-v7:$supportlib_version"
    implementation "com.android.support:recyclerview-v7:$supportlib_version"
    ...
}

Now, in your root build.gradle, have

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "$supportlib_version"
            }
        }
    }
}

that is, in every module and every configuration, when resolving dependencies, if it's a support lib (but not the multidex ones (there may be more exceptions)), force the version to your standardized support lib version.


Now in the age of jetpack and jetifier, it appears prudent to employ a variation (assuming you have migrated to the androidx versions):

Your e.g. app/build.gradle will now contain androidx dependencies, but libraries you use may still transitively pull in supportlib dependencies, which you still want on the same version (namely, 28.0.0) so that they can get properly jetified at build time.

So keep the root build.gradle parts as is, using 28.0.0 for the supportlib_version.


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.

You can't see the usages because its use is probably internal of another library (like google play services or squareup).

Just compile all examples that the little information window says, in your case:

Examples include com.android.support:animated-vector-drawable:25.2.0 and com.android.support:mediarouter-v7:24.0.0

Your

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

is version 25.2.0, 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.2.0

And do that for every example that the little information window says; in your case all the libraries that doesn't have the version 25.2.0.

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


i have looked through my entire project and i can not find any usage of versions 24.0.0

It is coming as a transitive dependency from one of your other dependencies.

First, though, fix the other issues in your build.gradle file, as they may clear up this problem as well:

  • Do not use + for a library version. Use a specific version.

  • Do not use play-services. Use the specific dependencies for the specific pieces of the Play Services SDK that you want. play-services brings in all of Play Services, making your app much bigger than it needs to be and slowing down your build times a lot.

  • Replace com.mcxiaoke.volley with the official Volley artifact (com.android.volley:volley:1.0.0)

If none of those clear up the issue, you can run a Gradle dependency report to see what your full tree of dependencies are. 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.

Tags:

Android

Gradle