Here is a much shorter way:
defaultConfig {
...
applicationId "com.blahblah.example"
versionCode 1
versionName "1.0"
setProperty("archivesBaseName", applicationId + "-v" + versionCode + "(" + versionName + ")")
//or so
archivesBaseName = "$applicationId-v$versionCode($versionName)"
}
It gives you name com.blahblah.example-v1(1.0)-debug.apk (in debug mode)
Android Studio add versionNameSuffix by build type name by default, if you want override this, do next:
buildTypes {
debug {
...
versionNameSuffix "-MyNiceDebugModeName"
}
release {
...
}
}
Output in debug mode: com.blahblah.example-v1(1.0)-MyNiceDebugModeName.apk