###简介
一个 Android Studio 项目中,会存在多个 .gradle 文件。其中, 项目根目录下存在一个 build.gradle 文件和一个 settings.gradle 文件;每一个 module 会存在一个 build.gradle 文件。
这里只是简单的讲解一下默认生成的 .gradle 文件的内容,更多 Gradle 的知识,访问:http://tools.android.com/tech-docs/new-build-system/user-guide
##项目根目录下的build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
-
默认的项目根目录下的 build.gradle 文件内容如上。
-
buildscript :用于设置驱动构建过程的代码。
jcenter():声明使用 maven 仓库。在老版本中,此处为 :mavenCentral()
- mavenCentral() :表示依赖从 Central Maven 2 仓库中获取。