Android - change flavor version name based on build type

前端 未结 4 916
清歌不尽
清歌不尽 2020-12-25 11:30

I want to change version name for app flavors but only if it\'s a debug build.

(e.g. debug builds will have versions like 1.0.1 D (DEBUG) 555 or 1.0.1 P (DEBUG) 555

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-25 12:10

    After hours of searching I've managed to remove all the changes made to the version name for the release build using this code

    applicationVariants.all { variant ->
        if (variant.buildType.name == 'release') {
            variant.mergedFlavor.versionName = android.defaultConfig.versionName;
        }
    }
    

提交回复
热议问题