app/build.gradle


android {

    applicationVariants.all { variant ->
        if (variant.buildType.name.equals("release")) {
            variant.outputs.each { output ->
                if (output.outputFile != null && output.outputFile.name.endsWith('.apk')) {
                    // Rename APK
                    def applicationId = defaultConfig.applicationId
                    def versionCode = defaultConfig.versionCode
                    def versionName = defaultConfig.versionName
                    def date = new java.text.SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date())
                    def newName = "${applicationId}_r${versionCode}_v${versionName}_${date}.apk"
                    output.outputFile = new File(output.outputFile.parent, newName)
                }
            }
        }
    }

}



[ Build > Generate Signed APK... ] 

 ./gradlew assembleRelease 

android.sample_r2_v1.1.0_20160101_002309.apk 


Posted by [czar]
,