How to Change APK File Name in Android

Today, I want to share with you some valuable file naming scripts for gradle to change your artifact output file names.

Gradle is a build system which lets you to produce both android archives(.aar) and android packages(.apk) easily.

In android studio the gradle build settings will produce a very boring standart artifact name for you like output files by default.

android gradle artifact apk
Default gradle output filename for apk. {appname}-{flavorname}-{variantname}.apk

To change this default file naming for your artifacts you can use the below scripts:

For your android library project you have to uncomment line 21.

For your android applications you have to uncomment line 21.

After making these changes, the output will be like that:

android artifact apk
The artifact name is changed after modifying the build.gradle file.

As you can see, the artifact output file name contains appname, current version, timestamp, flavor name, variant name.

If you have any questions, please ask in the comments below.

Thank you.