Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: what means that a dependency has a "promoted version"?

Today I discover this "experimental" screen in Android Studio.

enter image description here

Some updates says "Gradle promoted library version from..." what means with that?

(I checked the source code and found this: https://github.com/JetBrains/android/blob/master/android/src/com/android/tools/idea/gradle/structure/daemon/analysis/PsModuleAnalyzer.java#L59, but the link in the comment is not really useful)

like image 701
Matias Elorriaga Avatar asked Apr 04 '17 06:04

Matias Elorriaga


People also ask

How do I know if gradle dependency has new version?

Go to Android Studio -> Preferences -> Plugins (for Mac) and File -> Settings -> Plugins (for windows) and search “Check for Dependency updates plugin”. Install it and restart android studio. You will be able to see Dependencies tab on the right which will show if any dependency has a new update available.

How does gradle determine version?

In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here. If you are using the Gradle wrapper, then your project will have a gradle/wrapper/gradle-wrapper.

What does (*) mean in gradle?

Dependencies with the same coordinates that can occur multiple times in the graph are omitted and indicated by an asterisk(*).

Does Gradle dependencies order matter?

This isn't necessary. The order inside the dependencies { } block is preserved. You are kind of right. Dependency ordering is preserved, but for example all compile dependencies will be before testCompile dependencies no matter of how you order them.


1 Answers

This actually means, that Gradle had found some dependency conflict and used default conflict resolution strategy, which is to prefer a newer version of some dependency.

The link from the comment leads to the Gradle official user guide, where is dependency management is described. The most interesting part of it for you is "How dependency resolution works".

For example, you can have a gson-2.6.0 library in your dependencies, but some of your other dependencies need a gson-2.7 and it's loaded as a transitive dependency. This lead to the situation, that you have 2 different versions of the same library within you dependencies and this is called dependency conflict, because Gradle can't add both jars to the classpath at the same time. So it uses default conflict resolution strategy and promotes the declared version from 2.6.0 to the newer one 2.7.

like image 115
Stanislav Avatar answered Oct 26 '22 09:10

Stanislav