如何检查gradle依赖项是否有新版本 [英] How to check if gradle dependency has new version

查看:46
本文介绍了如何检查gradle依赖项是否有新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android Studio 中,当我在版本号中使用 +(如 com.android.support:recyclerview-v7:21.+)时,我得到避免在版本号"警告.当我使用特定版本号时,我不能总是使用最新版本.我的项目中有很多依赖项.如何检查依赖项是否具有较新版本?是否有 Android Studio 插件(或类似的插件)在有更新版本的依赖项时通知我?

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?

Android Studio 突出显示过时的 android 支持库和 Google Play 服务.但这不适用于其他自定义库.

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

推荐答案

这现在作为 Lint 检查内置到 Android Studio 中.您可以在此处启用它:

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

设置>编辑器>检查>可用的较新库版本"

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

本次检查说明:

新的库版本可用

此检测器与中央存储库进行检查,以查看是否有可用于此项目使用的依赖项的更新版本.这类似于 GradleDependency 检查,它检查 Android SDK 工具和库中可用的较新版本,但这适用于任何 MavenCentral 依赖项,并且每次都连接到库,这使得它更灵活但也很多 慢.

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.

编辑:以上应该只适用于 Android Studio 2.3.如果您使用的是旧版本(您应该更新),以下内容可能会有所帮助:

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:

请注意,您似乎必须启用检查才能手动运行它 - 因此(从 Android Studio 2.0 Beta 2 开始)您需要在设置中找到检查,启用它,然后按名称运行它,然后禁用再次(以恢复以前的性能).

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).

这篇关于如何检查gradle依赖项是否有新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆