Search code examples
androidgradledimensionsandroid-productflavors

Android Gradle Plugin 3.0.1 versionNameSuffix overriding with flavors dimensions


I have several flavors with 2 dimensions:

    flavorDimensions "buildType", "serverType"

    prod {
        dimension "serverType"
        versionNameSuffix "-prod"
    }

    development {
        dimension "buildType"
    }

    googlePlay {
        dimension "buildType"
        versionNameSuffix "-play"
        versionName "1.1"
    }

I want googlePlay flavor to override versionNameSuffix of prod flavor but it just appends suffixes to the final version name so I have version name like '1.1-prod-play' but I want it to be like '1.1-play'.

Could someone help me to achieve this?


Solution

  • Solution is to override versionName like this:

        prod {
            dimension "serverType"
            versionName globalConfig.androidVersionName + "-prod"
        }
    
        development {
            dimension "buildType"
        }
    
        googlePlay {
            dimension "buildType"
            versionName globalConfig.androidVersionName
        }
    

    Where globalConfig.androidVersionName is defined by me variable with version name.