android studio 生产apk,按照规则编译出命名好的apk

android studio 生产apk,按照规则编译出命名好的apk

在项目的build.gradle修改

1、添加编译日期,如第一段红色字体
2、修改编译出来的名字,如第二段红色字体
apply plugin: 'com.android.application'
在以上这句话的下面,添加编译时间
// define current compile date
String compileDate = new SimpleDateFormat("yyyy.MM.dd").format(new Date(System.currentTimeMillis()))
android {
    ....
// export apk file name
 applicationVariants.all { variant -> variant.outputs.all { output -> def apkName = 'Multiscreen_TV_' + variant.versionName + '_' + compileDate outputFileName = apkName + '_' + variant.buildType.name + '.apk' 
  }
 }
}
例如:编译出的软件apk名字是 Multiscreen_TV_1.1.1_2022.08.26_debug.apk

猜你喜欢

转载自blog.csdn.net/heshuangqiang/article/details/126549288