Dynamically configure the version number through gradle

def appVersionName = '0.0.1'
def appVersionCode = 1
android {
    
    
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
    
    
        versionCode project.hasProperty('VERSION_CODE') ? Integer.parseInt(VERSION_CODE) : appVersionCode
        versionName project.hasProperty('VERSION_NAME') ? String.valueOf(VERSION_NAME)  :appVersionName
    }
}

./gradlew assemble -PVERSION_CODE=1 -PVERSION_NAME=1.0.0

Guess you like

Origin blog.csdn.net/zxsean/article/details/106329091