How To Rename Flavor APK Files In Android Studio

We all want to customize naming our final APK files when generated since the default naming scheme of Android Studio with regards to flavors is somehow not specific to versions.

Using Gradle, you can do it like this:

Add that code inside the buildTypes{ } section of your flavor. The sample code will look for the .apk substring in the filename and rename it by adding an underscore plus the version name of the app and the .apk suffix.

Related Posts Plugin for WordPress, Blogger...

4 comments

    1. @rdb: hi, thanks for the correction. I corrected it. although this time i also added the option to convert the dot in the version name to underscore.

      1. I forgot to thank you for the post, it was exactly what I was looking for 🙂

        Also one can “chain” replace functions , something like this: “output.outputFile.name.replace(“.apk”, “-${variant.versionName}.apk”).replace(“-android”, “”)” – to remove “-android” in my case.

Leave a Reply

Your email address will not be published. Required fields are marked *