1

I want to add the version code as a suffix of versionNameSuffix. Currently, I have:

    debug {
        versionNameSuffix ".debug"
    }

How can I have something like:

    debug {
        versionNameSuffix ".debug.versionCode"
    }

My version code is based on the productFlavors:

    productFlavors {
        free {
            versionCode 123
        }
    }

@Resolution: I move versionCode out from productFlavors to root level and use the accepted anwser to inject versionCode in versionNameSuffix

1 Answer 1

3

Create constant version code in your app build.gradle

def versionCode = 1

Then in your flavours

debug {
    versionNameSuffix ".debug.${versionCode}”
}

Use the same version code in your defaultconfig also

defaultConfig {
    versionCode ${versionCode}        
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much for your answer, since I have versionCode basing on productFlavors, how can I get the versionCode? I updated the question. Thanks.
Try to create diffrent constants for different flavors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.