目的:掌握build.gradle的方法,更快的处理Android开发中的环境问题。
相关名词解释:
1.gradle:构建项目的管理工具。相对于XML(ANT和maven)配置更方便。
需要学习的只是
(一)外层项目的build.gradle文件解释:
1.注释的英文意思是:可以为所有的子项目、子模块添加构建需要的文件,但是不要添加应用的依赖在这里,它们应该添加到module的build.gradle文件中
2.闭包配置解析:
(1)jcenter():它是一个代码托管库,托管了很多Android开源的代码,声明这个配置可以引用jcenter的开源项目
(2)dependencies():classpath生命Gradle插件和它的版本号
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories