如何检查什么是在Gradle中使用的最新版本的依赖项 [英] How to check what is the latest version of a dependency to use in gradle
问题描述
依赖关系{
compile'com.android.support: mediarouter-v7:19. +'
}
但在最近的Android Studio版本,他们建议不要使用 +
,否则会导致错误。如何知道最新版本是什么?我可以尝试每一个19.yx的组合,直到gradle抱怨,但是真正的方法是检查什么?
解决方案
可能有其他方法,但这里是我使用的:
您可以使用Android Studio找到最新版本,在build.gradle编译行中替换您的库的版本号,只需 +
,然后单击窗口右上角的立即同步
。
在你的情况下,例如
依赖关系{
compile' com.android.support:mediarouter-v7:+'
}
Android Studio会弹出一个提示/灯泡,其中有选项替换为特定版本
您可以单击,它将填入 +
的最新版本。请看下面的screeshot:
如果第一次不行,让gradle完成同步,然后重试(用+代替+或者任何文件修改都可以,再次点击同步并提示灯泡
例如,对于您的库,我只需粘贴这一行 compile'com.android.support:mediarouter-v7: +'
在我的依赖关系下,并遵循上面的流程,Android Studio填充以下版本
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?
edit: sometimes, that page helps me figure it out.
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:
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
这篇关于如何检查什么是在Gradle中使用的最新版本的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!