Use a different naming convention for signed apks generated using the wizard on Android Studio

I have an application with more than a few buildFlavors and three different buildTypes .

I create signed apks from Build -> Generate Signed APK... (If there is no other way out, I would like to continue using the wizard, and not create a script, because I have a constantly growing set of applications and I do not want to change the script every time.)

The generated apks are named in the following pattern:

application-flavorName-buildType.apk

How can I change the naming pattern to something like this:

app_flavorName_buildType_versionCode.apk

The changes I want to make are:

  • versionCode file name with versionCode
  • Replace hyphens with underscores

I used this in ant using task , but not sure how to do it using gradle .

An attempt to define a solution for creating a name immediately in a new template, rather than trying to rename it after creating it. Is it possible?

I tried looking under Settings -> Gradle , but found nothing. Any other place I should look for?

+6
source share
1 answer

This is not exactly what you are looking for.

You can use your build.gradle to set this attribute:

 android { //... defaultConfig { //... project.ext.set("archivesBaseName", "app_"+ defaultConfig.versionCode); } } 

By assigning archivesBaseName , you will get something like:

 app_0.9.6-flavorName-buildType.apk 

This attribute requires gradle -plugin 1.3.1 or higher.

Otherwise, you will have to use the task to rename apk after build.

+2
source

All Articles