如何检查在 gradle 中使用的依赖项的最新版本是什么 [英] How to check what is the latest version of a dependency to use in gradle

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

问题描述

我总是像这样添加依赖项:

I've always added dependencies like this:

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

但在最新版本的 Android Studio 中,他们建议不要使用 +,因为它会导致错误.如何知道最新版本是什么?我可以尝试 19.y.x 的所有组合,直到 gradle 抱怨为止,但真正的检查方法是什么?

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?

有时,那个页面会帮助我弄清楚.

edit: sometimes, that page helps me figure it out.

推荐答案

可能还有其他方法,但这里是我使用的:

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

您可以通过将 build.gradle 编译行中库的版本号替换为 + 来使用 Android Studio 找到最新版本,然后单击 Sync Now 在窗口的右上角.

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.

以你的情况为例

依赖项{编译'com.android.support:mediarouter-v7:+'}

Android Studio 会弹出一个提示/灯泡,里面有选项Replace with specific version 可以点击,它会在+.请看下面的截图:

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:

如果这在第一次不起作用,让 gradle 完成它的同步,然后重试(用 + 替换 + 或任何文件修改都可以,再次单击同步,提示灯泡会出现).

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

例如,对于你的库,我只是在我的依赖项下粘贴了这一行 compile 'com.android.support:mediarouter-v7:+' 并按照上述过程,Android Studio 填写低于版本

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

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

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