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

前端 未结 8 1681
再見小時候
再見小時候 2020-12-29 20:24

I\'ve always added dependencies like this:

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

but in the recent versi

相关标签:
8条回答
  • 2020-12-29 20:45

    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

    0 讨论(0)
  • 2020-12-29 20:48

    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 > Messages

    Original Answer

    0 讨论(0)
  • 2020-12-29 20:49

    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"

    0 讨论(0)
  • 2020-12-29 20:51

    If it is a dependency that comes from Google's maven repository, the best way these days is to go to https://maven.google.com , where google now lets you browse all their libraries and see all the versions available, including the latest version. It looks like this:

    You can even do a search for a specific library, and then expand/collapse it as desired:

    0 讨论(0)
  • 2020-12-29 20:59

    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

    0 讨论(0)
  • 2020-12-29 21:04

    Recently I have found this,

    Go to File -> Project Structure

    Select the Module, where you want to add the dependency.

    Go to Dependencies Tab

    Click + and Choose Library Dependency

    Choose whichever Library you need from the list.

    (There is also an option for Search, never tried though.)

    Thats it.

    Done.

    Thank You.

    0 讨论(0)
提交回复
热议问题