How to update Gradle dependencies to their latest version

假装没事ソ 提交于 2019-11-30 00:06:54

This is all I've been able to come up with. I will happily accept another answer if there is a less manual method of doing this.

  1. In Android studio I replace every dependency version with a plus example: compile 'namespace:package1:+'

  2. Sync or build the project which will cause all the dependencies to be resolved to their latest version.

  3. In Android Studio place the cursor on each dependency line in build.gradle and press alt+enter a menu pops up and you can select Replace with specific version

Gorcyn

It is not a really good practice as libraries can include changes that may break your code.

A common "tolerated" syntax for

compile 'namespace:package:major_version.minor_version.revision'

would be like

compile 'namespace:package:1.0.+'

considering revision is used by the library authors as bug fixes and improvements updates

Note: I just did that and you could do

compile 'namespace:package:+'

Edit:
A Proof Of Concept of my latest comment you may want to test.
This was made in 5 minutes, so don't expect it to be perfect nor flexible.

Add to build.gradle:

plugins {
  id 'com.github.ben-manes.versions' version '0.17.0'
}

Then you can do gradle dependencyUpdates to get a report of new versions. Unlike the eponymous Maven plugin, there doesn't seem to be a way of automatically updating the build.gradle yet.

More documentation: https://github.com/ben-manes/gradle-versions-plugin

I suffer from it, too. And the best way to check dependencies, even manually, is to go through Project Structure and search for the dependency name and see if there is a newer version.

The problem that this query only checks for the dependencies present in the Maven repository. At least it already goes for Google's.

Note: If you choose to add the dependency with the new version, this will add a duplicity in the your App Gradle, so be sure to delete the old dependency row.

#

Another possible quick fix is through the command line:

./gradlew app: dependencies

This will generate an output like the one below. Note that the asterisk points to a possible new existing version.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!