2

I have split my .APK file into multiple smaller sized .APKs using this

As far as my understanding goes. The Gradle system generates multiple .APK files for different ABIs that I am supporting. Each .APK follows the naming convention as mentioned here

Is there any way I can modify the name of the .APK files generated? I would like to either add a suffix / prefix / in between some string value which would help me identify the .APK being generated. Specifically the gitSha.

PunK _l_ RuLz
  • 621
  • 6
  • 20

2 Answers2

4

Yes, use outputFileName in your build.gradle.

Here's an example:

android.applicationVariants.all { variant ->
    variant.outputs.all { output ->
        outputFileName = applicationName + "-" + output.getFilter(com.android.build.OutputFile.ABI) + "-" + variant.name + ".apk"
    }
}

Assuming app name is "MyApp", APK name will be MyApp-x86-debug for a debug build for the x86 ABI.

Mateus Gondim
  • 5,362
  • 6
  • 31
  • 51
0

You can get Git Hash using command below in build.gradle

def gitCommitHash = "git rev-parse --verify --short HEAD".execute().text.trim()
variant.outputs.all {
    outputFileName = "ApplicationName-${defaultConfig.versionName}-${gitCommitHash}-${getFilter(ABI)}-${variant.buildType.name}.apk"
}

This would generate .apk filename be like ApplicationName-v0.1.0-e2c3b62-x86_64-release.apk