赞
踩
打包的名字如 app.1.0.1_relase_201283893.apk
打包命令
flutter build apk
实现
配置安卓项目的中的build.gradle (android/app/build.gradle )
新增 android { 内 applicationVariants.all 配置
- applicationVariants.all { variant ->
- variant.outputs.all {
- def appName = "拓车服管家" // 文件名
- def version = variant.versionName // 版本号
- def buildType = variant.name // 包类型,debug 还是 release
- def createTime = new Date().format('MMddHHmm') // 打包时间 2021_09_25_16_45_52
- if (buildType == "debug") {
- outputFileName = "${appName}_${version}_${buildType}_${createTime}.apk"
- }
- if (buildType == "release") {
- outputFileName = "${appName}_${version}_${buildType}_${createTime}.apk"
- }
- }
- }
def createTime = new Date().format('MMddHHmm') 这样的打包出来的是时间戳
def createTime = new Date().format('yyyy_MM_dd HH:mm:ss')
app_1.2.3_release_2024_04_10 09:43:08
当使用 下面的 cpu 架构进行打包的时候,上面代码会报错。
flutter build apk --split-per-abi
对配置进行优化
- applicationVariants.all { variant ->
- variant.outputs.all { output ->
- def appName = "快通助手" // 文件名
- def createTime = new Date().format('yyyy_MM_dd HH:mm:ss') // 打包时间 2021_09_25_16_45_52
- def cpu = output.getFilter(com.android.build.OutputFile.ABI)!=null
- ? output.getFilter(com.android.build.OutputFile.ABI)
- : "all" // 默认值;
- outputFileName = "${appName}_${defaultConfig.versionName}_${createTime}_${variant.flavorName}_${variant.buildType.name}-${cpu}.apk"
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。