首先Gradle其实就是一个build toolkit,可以方便的管理依赖包和定义你自己的build逻辑,下面是module中的一个build.gradle
apply plugin: 'com.android.application'
//android项目build时的配置
android {
compileSdkVersion 23 //编译用的SDK版本
buildToolsVersion "23.0.1" //build工具版本
//defaultConfig配置AndroidManifest.xml里的项目,这里的配置可以覆盖manifest里的配置
defaultConfig {
applicationId "com.example.yf.demo"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
//配置如何构建和打包你的App,debug和release
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
//配置此模板的依赖
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}