在网上找的一些知识点;地址:http://stormzhang.com/devtools/2014/12/18/android-studio-tutorial4/
以便自己以后理解使用:
//声明是Android程序
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
//获取当前时间
def releaseTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
android {
//签名
signingConfigs {
debug{
//debug模式
}
release {
keyAlias 'lambda'
keyPassword '940219'
storeFile file('D:/lambda.jks')
storePassword '940219'
}
}
//编译SDK的版本
compileSdkVersion 25
//build tools的版本
buildToolsVersion "25.0.1"
defaultConfig {
//应用的包名
applicationId "hwelltech.com.lambdademo01"
//SDK最低版本
minSdkVersion 24
//目标SDK版本
targetSdkVersion 25
//代码版本
versionCode 1
//版本名字
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
//java版本
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
debug{
//debug模式
// 显示Log
buildConfigField "boolean", "LOG_DEBUG", "true"
versionNameSuffix "-debug"
minifyEnabled false
zipAlignEnabled false
shrinkResources false
signingConfig signingConfigs.debug
}
release {
// 不显示Log
buildConfigField "boolean", "LOG_DEBUG", "false"
zipAlignEnabled true
// 移除无用的resource文件
shrinkResources false
//是否进行混淆
minifyEnabled false
//混淆文件的位置
//第一个文件位置**/tools/proguard/proguard-android.txt**
//第二个文件位置**app/proguard-rules.txt**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//签名
signingConfig signingConfigs.release
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
// 输出apk名称为lambda1.0_2015-01-15_wandoujia.apk
def fileName = "lambda_${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
}
// 移除lint检查的error
lintOptions {
abortOnError false
}
// 友盟多渠道打包
productFlavors {
wandoujia {}
_360 {}
baidu {}
xiaomi {}
tencent {}
taobao {}
}
productFlavors.all { flavor ->
flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
/**
* 或者这个
* android {
productFlavors {
xiaomi {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "xiaomi"]
}
_360 {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "_360"]
}
baidu {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "baidu"]
}
wandoujia {
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "wandoujia"]
}
}
}
*/
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
}