你好,我是android开发和JAVA领域的新手。我有安卓工作室和一个新项目。我在项目属性中从maven存储库中添加了一个对库的依赖。例如,如果一年后有人将在maven存储库中更新这个库,我将需要更新链接到这个库的项目设置中,还是它将自动加载新版本的库?谢谢。
在这里,我的.gradle配置:
apply plugin: 'com.android.library'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.robbypond:mopub-android-sdk:3.2.2d'
compile 'com.googlecode.android-query:android-query:0.25.9'
}发布于 2014-12-15 11:00:58
只要您将依赖定义为固定版本(如com.robbypond:mopub-android-sdk:3.2.2d),该依赖关系就不会被更新。根本不需要更新依赖项,因为在释放依赖项之后,它的内容应该是固定的。
如果您想要“自动升级”到较新的版本,则可能需要使用“动态版本”。你可以这样做:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.robbypond:mopub-android-sdk:3.2.+' // note the + instead of 2d
compile 'com.googlecode.android-query:android-query:0.25.+' // note + instead of 9
}其优点是,只有当版本号的最后一部分发生变化时,才能获得库的更新版本。当库作者坚持使用语义版本化时,您只会得到错误修复更新,而不会因为修改了API而引入编译失败。
另一种选择是完全省略版本号。这带来了获得较新版本API的风险,可能会破坏您的构建。我提这件事只是为了完整:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.robbypond:mopub-android-sdk' // note the missing :3.2.2d
compile 'com.googlecode.android-query:android-query' // note the missing :0.25.9
}https://stackoverflow.com/questions/27482354
复制相似问题