Skip to content

Auto Rename APK

Bhaumik Soni edited this page May 15, 2017 · 1 revision

1. Create project level artifacts.gradle file

2. Copy below code

android.applicationVariants.all { variant ->
    def appName
    //Check if an applicationName property is supplied; if not use the name of the parent project.
    if (project.hasProperty("applicationName")) {
        appName = applicationName
    } else {
        appName = parent.name
    }

    variant.outputs.each { output ->
        def newApkName
        newApkName = "${appName}-${output.baseName}-${variant.versionName}.apk"
        output.outputFile = new File(output.outputFile.parent, newApkName)
    }
}

3. Open app level build.gradle file and add below line at bottom of file

apply from: "../artifacts.gradle"

4. Sync and run app. Check your apk name in apk directory !!!!