How to change apk name by using gradle like this format?

This may be the shortest way:

defaultConfig {
    ...
    applicationId "com.blahblah.example"
    versionCode 1
    versionName "1.0"
    setProperty("archivesBaseName", applicationId + "-v" + versionCode + "(" + versionName + ")")
}

buildType: like so

buildTypes {
    debug {
        ...
        versionNameSuffix "-T"
    }
    release {
        ...
        versionNameSuffix "-R"
    }
}

Keep in mind, Android Studio adds versionNameSuffix by build type name by default, so you may not need this.

Upd. In new versions of Android Studio you can it write little shorter(thanks for szx comment):

defaultConfig {
    ...
    archivesBaseName = "$applicationId-v$versionCode($versionName)"
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)