How to check what is the latest version of a dependency to use in gradle

I’ve always added dependencies like this:

dependencies {
    compile 'com.android.support:mediarouter-v7:19.+'
}

but in the recent versions of Android Studio, they recommend not to use the + as it can lead to errors. How to know what’s the latest version? I can try every combination of 19.y.x until gradle complains, but what’s the real way do check?

  • AppCompat v7 r21 returning error in values.xml?
  • enable Annotation Processors option in Android Studio 2.2
  • Is there a way to have an Android process produce a heap dump on an OutOfMemoryError?
  • Android Fragment handle back button press
  • Get product flavor or build variant in an android app
  • Store Android SQLite
  • edit: sometimes, that page helps me figure it out.

  • java.lang.IllegalStateException: YouTubeServiceEntity not initialized error when using YouTubePlayerApi
  • Avoiding content type issues when downloading a file via browser on Android
  • AlarmManager not working
  • Dialog with transparent background in Android
  • Retrofit2 Android: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
  • How to use the new manifest merger (of Android Studio and Gradle)?
  • 5 Solutions collect form web for “How to check what is the latest version of a dependency to use in gradle”

    There may be other ways, but here is what i use:

    You can find out the latest version using Android Studio by replacing the version number of your library in build.gradle compile line, with just + , and click on Sync Now in upper right corner of the window.

    in your case, for example

    dependencies {
    compile 'com.android.support:mediarouter-v7:+'
    }

    Android Studio will pop up a hint/bulb, which has options Replace with specific version you can click, which will fill-in the latest version in-place of +. Please see below screeshot:

    android studio hint

    If this doesn’t work the first time, let gradle complete its sync, and retry (replace + with + or any file modification will do, click the sync now again and hint bulb will show up).

    For example, for your library, i simply pasted this line compile 'com.android.support:mediarouter-v7:+' under my dependencies and followed the above process, Android Studio filled in with below version

    .

    Relying on latest version is indeed a dangerous thing to do. Your build can break without you changing anything, just because some library broke backwards compatibility.

    The easiest way to know when new version of a library is out is to subscribe to new version notifications in Bintray.

    Just click on the “Watch” button on the package page and you’ll get an email every time new version is out. Then you’ll be able to update the dependency, test it, and only then commit the build script with the new version.

    Watch package in Bintray

    As already mentioned by some other answers you should not use + in dependencies because it may lead to unpredictable builds, so its always better if you first test your builds once a new update is available.

    With android studio 2.2 and above Project Structure will show you the latest dependencies available.

    1. Activate it by going to Android Studio > Settings > Build,
      Execution, Deployment > Gradle > Experimental and check the Use
      new Project Structure dialog
    2. Then open it by going to File >Project Structure > Image showing updates dialogMessages

    Original Answer

    Avoid to use + in version declare.

    You can try andle to check if dependency out of date, also the build tool version and sdk version.

    Simple three step:

    1. install:

        $ sudo pip install andle
    

    2. set sdk:

        $ andle setsdk -p <sdk_path>
    

    3. update depedency:

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

    –dryrun: only print result in console

    –remote: check version in jcenter and mavenCentral

    the answer of ashoke is correct if you want the latest version.

    But if you just want to replace “+” by the version you are currently using (therefor protection yourself against bug in future update)

    eg:

     compile 'com.android.support:appcompat-v7:21.0.+'
    

    to

     compile 'com.android.support:appcompat-v7:21.0.3'
    

    (but not using 23.0.1)

    this is the easiest way, no software needed:

    run

    $ ./gradlew clean tasks --debug > ~/whatever.txt
    

    then look for “com.android.support:appcompat-v7:21.0.”

    a few line below you will see

    “Using com.android.support:appcompat-v7:21.0.3 from Maven repository”

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.