254
votes

In Android Studio when I use + in version number (like com.android.support:recyclerview-v7:21.+) I get "Avoid using + in version numbers" warning. When I use a specific version number I can't always use the latest version. I have a lot of dependencies in my project. How do I check if a dependency has a newer version? Is there an Android Studio plugin -or something like that- to notify me when there is a newer version of a dependency?

Edit: Android studio highlights the outdated android support libraries and Google play services. But this is not available for other custom libraries.

enter image description here

9
For developers who are updating the library see: How to update library for new version in Bintray?Suragch
In at least Android 3.0, updates for custom libraries now show the same notification as you have in your question image for the support library.Suragch
@Suragch this doesn't work for some dependencies for me in android studio 3.0.1Rémy
We can use gradleplease.appspot.com for checking new library versionAliaksei Kisel

9 Answers

220
votes

This is now built-in to Android Studio as a Lint check. You can enable it here:

Settings > Editor > Inspections > "Newer Library Versions Available"

The description for this inspection:

Newer Library Versions Available

This detector checks with a central repository to see if there are newer versions available for the dependencies used by this project. This is similar to the GradleDependency check, which checks for newer versions available in the Android SDK tools and libraries, but this works with any MavenCentral dependency, and connects to the library every time, which makes it more flexible but also much slower.

Because of the slowdown this can introduce I'd recommend running it manually periodically, rather than having it always on. You can do this by:

Analyze > "Run Inspection By Name"

Then search for "Newer Library Versions Available", and run it on your module.

Edit: The above should just work as of Android Studio 2.3. If you're on an old version (you should update) the following may help:

Note that it appears you must have the inspection enabled in order to run it manually - so (as of Android Studio 2.0 Beta 2) you need to find the inspection in settings, enable it, then run it by name, then disable it again (to regain previous performance).

280
votes

UPDATE (05/23/18):

The newer version of Android Studio does not show version updates in the Project Structure dialog. Instead, Adam-s answer is the correct one for Android Studio 3+

Analyze > "Run Inspection By Name"

Then search for "Newer Library Versions Available"

PREVIOUS WAY:

As of Android Studio 2.2, a new Project Structure dialog shows the list of dependencies your app is using with the available updates from local AND remote repositories as well.

  • Activate it by going to Android Studio > Settings > Build, Execution, Deployment > Gradle > Experimental and check the Use new Project Structure dialog (Thanks @jessehensold)
  • Then open it by going to File > Project Structure > Messages

enter image description here

For older version of Android Studio, see other responses below.

74
votes

Aside from the Android Studio's built-in feature, there's nice gradle plugin called Gradle Versions Plugin that does exactly what you want, with the benefit of being plain gradle extension, which means being NOT bond to any IDE - just pure Gradle thing.

Gradle Versions Plugin can create reports in human readable plain text form, but can also dump it as JSON or XML which is pretty useful for automated/scripted processing.

Usage is pretty simple. Once added to your gradle file, you just do:

> ./gradlew dependencyUpdates

and it should produce project dependency report that looks like this:

------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------

The following dependencies are using the latest milestone version:
 - com.github.maksim88:PasswordEditText:v0.9
 - com.marcinorlowski:webnet-log:1.0.3
 - com.nulab-inc:zxcvbn:1.2.2

The following dependencies exceed the version found at the milestone revision level:
 - com.hannesdorfmann.fragmentargs:annotation [4.0.0-SNAPSHOT <- 3.0.2]
 - com.hannesdorfmann.fragmentargs:bundler-parceler [4.0.0-SNAPSHOT <- 3.0.2]
 - com.github.bumptech.glide:glide [3.7.0 <- 3.6.1]
 - com.hannesdorfmann.fragmentargs:processor [4.0.0-SNAPSHOT <- 3.0.2]

The following dependencies have later milestone versions:
 - com.github.PhilJay:MPAndroidChart [v2.2.5 -> v3.0.1]
 - com.android.support:appcompat-v7 [25.1.0 -> 25.1.1]
 - com.jakewharton:butterknife [8.4.0 -> 8.5.1]

Generated report file build/dependencyUpdates\report.txt

See docs for extensive usage examples.


NOTE: as of writing this answer (2017-01), versions higher than 0.17.0 produce more output in plan text format, incl. project URLs thus making the whole output bloated.

21
votes

See File > Project Structure, then click "Suggestions". I know, this solution was suggested by Hemant Sharma and Jeremías Gersicich, but Android Studio has changed it in 3.4.1 version.

enter image description here

It will help in most cases, but sometimes libraries change their ids (paths). So you should sometimes visit their sites and see why these libraries didn't update so long. Then update manually.

15
votes

DEPRECATED - SEE ACCEPTED ANSWER FOR MODERN WAY

The tool I present below doesn't work on new versions of Android Studio / Gradle and its author no longer maintains it (as of 30/10/2016). Therefore, the solution presented in the accepted answer should be used unless working with old version of Android Studio.


As of January 2016, there's a plugin for Android Studio that does something similar, called Dependencies Version Checker, and whose sources can be found on GitHub.

It can be added through the built-in interface (Settings > Plugins > Browse repositories...) :

What it looks like inside the native interface

After installation and restart, the following tab appears in the UI:

New UI tab which appears after restart.

The relevant build.gradle should then be pasted into the left side of the VersionChecker panel, and the Version Check button pressed. The result is a table that appears on the right side, which includes the latest versions of the libraries used in the pasted script (as shown in the image above).

2
votes

For support library (com.android.support) dependencies, there is a better option - andle

It can query jcenter and maven center as well.

Simple three step to update all project at once.

1. install:

    $ sudo pip install andle

2. set sdk:

    $ andle setsdk -p <sdk_path>

3. update depedency:

    $ andle update -p <project_path> [--dryrun] [--remote] [--gradle]

--dryrun: only print result in console

--remote: check version in jcenter and mavenCentral

--gradle: check gradle version

See https://github.com/Jintin/andle for more information

1
votes

I was dealing with this same problem and tried the answer https://stackoverflow.com/a/35371234/6412430

What really worked for me on Android Studio 3.4.1 was:

File -> Project Structure -> Dependencies

Once you have reached this point all dependencies that are included on your project or module will be listed. The ones that are outdated will be underscored and when you select one, the details of it will be shown giving you the options to updated the Variable (if you have it separated from the declaration) or the Dependency.

Kind of late but this was what worked for me.

0
votes

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.

enter image description here

-1
votes

To get updated or recommended for your project dependency should be same as android project

FILE -> Project Structure -> MODULES(app) -> Dependencies

When you reach the dependencies tab Click on + button which is placed on the top right corner of the window. When you click on + Select Library Dependency it will open New window for Choose Library Dependency Search for your dependency in the search box, all the listed Android dependencies are updated.