How to update Gradle dependencies to their latest version

Jared Kells picture Jared Kells · Feb 16, 2015 · Viewed 29.9k times · Source

Is there an easy way to get gradle to update dependencies to their latest available version?

For build reproducibility all my dependencies are defined with a version number like this in my build.gradle file:

dependencies {
    compile 'namespace:package1:version'
    compile 'namespace:package2:version'
    compile 'namespace:package3:version'
}

Periodically I want to update every package to their latest version. Typically this is the first thing I do for a new sprint after making a release.

It's a real pain doing this manually for each package. Ideally I would like a command to update the build.gradle file for me but at the very least a command that prints out which package needs an update and what the latest version number is.

In ruby land I would run bundler update.

Answer

Jared Kells picture Jared Kells · Feb 16, 2015

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