如何强制库使用 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.
无论如何,我在这里找到了解决方案.
Anyway, I found a solution here.
复制到这里以防万一:
在你的根 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 force build tools 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!