Gradle has made the lives of Android developers quite easy- just add one
dependency in the build.gradle, and the required library is seamlessly included in the build. But what happens when two dependencies have a dependency on different versions of the same library? Consider the following example. Both libraries in the below code have an internal dependency on a library “org.hamcrest:hamcrest-core”
So if both the dependencies are internally using different versions of the same library, then which version finally gets included in the build? The answer is- the highest version gets included in the build. Run the following command in the module in which the dependencies are declared.
./gradlew dependencies.
The output of the above command is given below which clearly indicates that gradle automatically upgrades the hamcrest library version from 1.1 to 1.3 in the final build.