android {
// 输出版本名到 build 目录下的 version_name.txt 文件
applicationVariants.all { variant ->
project.tasks["assemble${variant.name.capitalize()}"].doLast {
new File(project.buildDir, "version_name.txt").withWriter('utf-8') {
it.write(variant.versionName)
}
}
}
}