第三方库上的gradle force构建工具版本? [英] gradle force build tools version on third party libraries?

查看:648
本文介绍了第三方库上的gradle force构建工具版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何强制一个库使用sdk build tools 19.1.0或更高版本,而不需要手动/编辑库的build.gradle文件?



我保留使用库时出现此错误...

 错误:SDK Build Tools修订版(.......)是对于项目'太低':somelibrary'。最低要求是19.1.0 


解决方案

这是超出我的理解。许多人使用他们不拥有的图书馆项目,不得不与Jenkins一起构建或有其他理由不要触摸它们,也不想将它们分发给个人使用。



无论如何,我在这里找到了一个解决方案



在你的root build.gradle中添加

  ext {
compileSdkVersion = 20
buildToolsVersion =20.0.0
}
子项目{子项目 - >
afterEvaluate {
if((subproject.plugins.hasPlugin('android')|| subproject.plugins.hasPlugin('android-library'))){
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}

这会将compileSdkVersion和buildToolsVersion应用于您拥有的任何Android模块。



并在您的主项目构建中。 gradle更改依赖关系如下:

  compileSdkVersion rootProject.ext.compileSdkVersion 
buildToolsVersion rootProject.ext.buildToolsVersion

基本上,您定义了一次,可以在任何地方使用。

干杯。


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

解决方案

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.

Will copy it here just in case:

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
            }
        }
    }
}

This will apply compileSdkVersion and buildToolsVersion to any android modules you have.

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.

Cheers.

这篇关于第三方库上的gradle force构建工具版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆