0

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

Anh-Tuan Mai
  • 1,129
  • 19
  • 36

1 Answers1

2

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}        
}
Naveen
  • 350
  • 2
  • 12