承接上一篇:https://blog.csdn.net/weixin_42602900/article/details/107919563
本篇通过修改build.gradle配置文件,然后使用grade命令,通过传参来动态打包应用版本号和版本名称。
- 修改build.gradle配置文件:
`def appVersionCode = 108
def appVersionName = '1.0.8'
android {
signingConfigs {
myrelease {
storeFile file('../test.keystore')
storePassword 'test123'
keyAlias 'key0'
keyPassword 'test123'
}
}
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.mkst.umap"
minSdkVersion 19
targetSdkVersion 28
// versionCode 108
// versionName "1.0.8"
versionCode project.hasProperty('VERSION_CODE') ? Integer.parseInt(VERSION_CODE) :appVersionCode
versionName project.hasProperty('VERSION_NAME') ? String.valueOf(VERSION_NAME) :appVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}`
- 控制台输入gradle命令:“gradlew assembleRelease -PVERSION_CODE=109 -PVERSION_NAME=1.0.9”,如下图
参考博客:https://blog.csdn.net/bobby_fu/article/details/103069780