Nomenclature of Apk

We are using the Default apk naming but it doesn’t have any information about the app version name, version code , apk name is too big , even after downloading the apk you won’t be able to see full apk name in small devices.

To check app version number code you have to go to settings -> App and then figure out the version code that will be painful. To solve it we decided to change the naming of our apk.

Code which we added in build.gradle -:

ext.abiStrings = ['armeabi-v7a': "arm", x86: "x86"]

import com.android.build.OutputFile

android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def fileName = variant.variantData.variantConfiguration.buildType.name + "_" + project.abiStrings.get(output.getFilter(OutputFile.ABI)) + "_" + variant.versionName + "_" + output.versionCode + ".apk"
output.outputFile = new File(output.outputFile.parent, fileName)
}
}

What exactly the above code will do -:

  • It will first append buildtype in the apk name ( “debug” , “release”).
  • Then abi format “arm” or “x86” , we added abiStrings to avoid adding “armeabi-v7a” in the apk instead of that we used small pretty name for it in abiStrings.
  • Followed by app version name and version code.

Earlier Format -:

New format -: