問題描述
如何強(qiáng)制庫使用 sdk 構(gòu)建工具 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
推薦答案
缺乏簡單的方法超出了我的理解.很多人使用他們不擁有的庫項(xiàng)目,必須使用 Jenkins 構(gòu)建或有其他原因不接觸它們并且不想將它們分叉供個人使用.
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.
復(fù)制到這里以防萬一:
在你的根 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 應(yīng)用于您擁有的任何 android 模塊.
This will apply compileSdkVersion and buildToolsVersion to any android modules you have.
并且在您的主項(xiàng)目的 build.gradle 中將依賴項(xiàng)更改為:
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.
干杯.
這篇關(guān)于第三方庫上的 gradle force build tools 版本?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!