Search code examples
androidgradleapkandroid-install-apk

Suffix / Prefix / InBetween the .APK name when split by ABI


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.


Solution

  • 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.