Tech Blogging‎ > ‎

All Libraries Must Use the Exact Same Version

posted Jul 31, 2017, 8:40 AM by Haris Hashim   [ updated Jul 31, 2017, 8:16 PM ]

Recently I have encountered this warning in Android Studio build.gradle. 

All libraries must use the exact same version specification (mixing versions can lead to runtime crashes).

"All libraries must use the exact same version specification (mixing versions can lead to runtime crashes)."

The next line in the error give some hints.

"Found versions 25.3.1, 23.1.1. Examples include and"

It is not a show stopper since the project build just fine and did not crash. But after few project having same error, it annoys me enough to investigate and fix.


Open cmd shell, change directory to project root folder and execute bellow gradle command.

gradlew -q dependencies app:dependencies --configuration compile

It will list all dependencies and sub dependencies. The problem is that this project depend on dependency that in turn depend on different support libraries version. Knowing that the project depends on support library 25.3.1 and hint is given that version 25.3.1 and 23.1.1 is found. So the culprit must be a dependency that make use of version 23.1.1. Search or eyeball for such dependency in the list.

Troubleshooting and finding the root cause

Base on above picture, we need to do something about secretsauce component that depends on support library version 23.1.1.

In this particular case, since secretsauce is an opensource library. My quick and easy solution is to add it as part of the project and rebuild it with newer version of support library. 

Add the Library

Download the code from github as zip. Copy the secretsauce sub folder as in bellow picture into project root folder.

Add secretsauce as library in the project

Add secretsauce into the project by changing project settings.gradle to include the library.

Change project settings.gradle

The library is now integrated into the project and we can use "compile project(':SecretSauce')" in app module build.gradle file. Don't forget to comment out the old secretsauce dependency.

Add librart into app module and comment out old dependency

Change the Version Number

Modify secretsauce module build.gradle to change support library version number.

Chang support library version number

Sync and build the project. Fix any errors encountered.

Code in Github

Here is a sample project in github as demonstration of the final and working result. Have fun!

Feel free to message me in GitHub if there is question!