废话不说,直接上代码
注意层级结构,你懂的,没有格式化,凑合着看吧~
apply plugin: 'com.android.application'
apply plugin: 'AndResGuard'
//应用 Bugtags 插件
apply plugin: 'com.bugtags.library.plugin'
def appName() {
return "阅猎小说"
}
String releaseTime() {
Date date = new Date()
String dates = date.format("yyyy_MM_dd_hh_mm_ss", TimeZone.getTimeZone("UTC"))
return dates
}
//======================
android {
buildTypes {
release {
//3.0+版本
applicationVariants.all { variant ->
//这个修改输出的APK路径
if (variant.buildType.name != "debug") {//防止AS无法安装debug包(apk)
variant.getPackageApplication().outputDirectory = new File(project.rootDir.absolutePath + "/apk")
}
variant.getPackageApplication().outputScope.apkDatas.forEach { apkData ->
//这个修改输出APK的文件名
apkData.outputFileName = "${appName()}" +
variant.versionName + "_" +
"${releaseTime()}" + "_" +
variant.flavorName + "_" +
variant.buildType.name + "_" +
variant.signingConfig.name +
".apk"
}
}
}
}
}