Name your .apk and .aab files

Tram Ho

This article will explore how to rename your artifacts, to convey meaning.

Why?

Use cases:

  1. When your application has different "flavors", you need identifiable outputs.
  2. When you produce multiple versions at the same time, you need to tell which artifact it is.

To check your current artifact name, simply run the Gradle task, assembleDebug . If you haven't modified it, your output will be app-debug.apk

It is better to have a more informative and meaningful name, such as the following:

The above sample will create a name like:

By using this template, you know what this APK is.

Option 1

You can find this naming in many answers on StackOverflow.

DSL version:

This works well for APKs but not for app bundles.

Output:

Option 2

The following implementation is easy and simple, but as the attribute of "archivesBaseName", it will only set the base name, not the full file name.

DSL version:

Output:

The "-release" section is added automatically.

Compare performance

In this section, Option 1 will be compared to Option 2.

The following metrics are implemented on a 7-module project by running the following tasks:

  • clean
  • assembleDebug
Runs Option 1 Option 2
first 15,643 16,519
2 16,539 14.515
3 14.39 16,592
4 16,536 14.506
5 16.9 15,391
medium 16.0016 15.5046

Compare 2 options

Conclude

As you can see from the charts and figures above, the two options have identical performance, the difference is not obvious.

Remember: When naming your artifacts, make sure you are giving them meaningful names.

Ref: https://www.giorgosneokleous.com/2019/12/01/name-your-apk-aab-files/

Share the news now

Source : Viblo