如何界定普通的Andr​​oid属性使用摇篮所有模块 [英] How to define common android properties for all modules using gradle

查看:142
本文介绍了如何界定普通的Andr​​oid属性使用摇篮所有模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建AndroidStudio一个简单的项目有几个模块。每个模块的摇篮脚本包含以下code:

I create a simple project in AndroidStudio with a few modules. Each module's gradle script contains the following code:

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.1"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 18
    }
}

我怎样才能推动这一code主build.gradle脚本(项目剧本)?这code是适用于所有的子模块。

How can I move this code to the main build.gradle script (project's script)? This code is common for all the submodules.

推荐答案

在主体工程build.gradle你应该写类似下一:

In build.gradle of main project you should write something like next:

project.extensions.add("buildToolsVersion", "19.0.3")

在子项目,你可以使用这个扩展名:

In subproject you can use this extensions:

buildToolsVersion rootProject.buildToolsVersion

更多信息,你可以找到的这里

这篇关于如何界定普通的Andr​​oid属性使用摇篮所有模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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