我从命令行构建APK如下
./gradlew assembleProductionRelease
是否有任何配置参数可以自动将buildNumber
和versionNumber
添加到APK文件名中?默认情况下,APK文件将命名为app-production-release
。
答案 0 :(得分:1)
您可以尝试/调整此代码(将其添加到build.gradle):
applicationVariants.all { variant ->
variant.outputs.all { output ->
def sep = '_'
def version = variant.versionName
def build = variant.versionCode
outputFileName = "${rootProject.name}${sep}" +
"${variant.buildType.name}${sep}" +
"${version}${sep}" +
"build${sep}${build}.apk"
}
}