找到新版本的最佳方法是Android Studio项目中使用的外部库

Chr*_*hen 5 android maven android-studio android-gradle-plugin jcenter

我是Android开发的新手.因此外部库(也称为依赖项)的定义build.gradle类似于

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v13:21.0.0'
    compile 'com.squareup.dagger:dagger:1.2.1'
    compile 'com.google.code.gson:gson:2.1'
    compile 'de.greenrobot:eventbus:2.4.0'
}
Run Code Online (Sandbox Code Playgroud)

有没有一种简单的方法可以找出这些库是否有更新的更新版本?我注意到Android Studio提醒了新版本,gson但没有提供其他库.

我来自iOS背景,CocoaPods是我们用来管理外部库的工具.使用pod outdated命令,很容易找出哪些库有新版本进行升级.

tac*_*lux 6

有一个名为"可用的新库版本" 的lint选项.

您可能还需要将它添加到build.gradle中:

android {
    ...

    lintOptions { warning 'NewerVersionAvailable' }
}
Run Code Online (Sandbox Code Playgroud)

然后,您可以运行Analyze > Run Inspection By Name... > Newer Library Versions Available以获取过期依赖项的列表.