第三方库上的 gradle 强制构建工具版本? [英] gradle force build tools version on third party libraries?
问题描述
如何强制库使用 sdk 构建工具 19.1.0 或更高版本,而无需分叉/手动编辑库的 build.gradle 文件?
how can I force a library to use sdk build tools 19.1.0 or above without forking/manually editing the build.gradle file for the library?
我在使用库时不断收到此错误...
I keep getting this error when using libraries...
Error:The SDK Build Tools revision (.......) is too low for project ':somelibrary'. Minimum required is 19.1.0
推荐答案
缺乏简单的方法超出了我的理解.许多人使用他们不拥有的图书馆项目,必须与 Jenkins 一起构建或有其他理由不接触它们并且不想将它们分叉以供个人使用.
The lack easy way to do it is beyond my understanding. Tons of people use library projects that they don't own, have to build with Jenkins or have other reasons not to touch them and don't want to fork them for personal use.
无论如何,我在这里找到了一个解决方案.
将它复制到这里以防万一:
Will copy it here just in case:
在你的 root build.gradle 中添加
In you root build.gradle add
ext {
compileSdkVersion = 20
buildToolsVersion = "20.0.0"
}
subprojects { subproject ->
afterEvaluate{
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
这会将 compileSdkVersion 和 buildToolsVersion 应用到您拥有的任何 android 模块.
This will apply compileSdkVersion and buildToolsVersion to any android modules you have.
并在您的主项目的 build.gradle 中将依赖项更改为:
And in your main project's build.gradle change dependencies to this:
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
基本上,您只需定义一次即可在任何地方使用.
Basically you are defining them once and could use from anywhere.
干杯.
这篇关于第三方库上的 gradle 强制构建工具版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!