Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

android - gradle force build tools version on third party libraries?

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...