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
RunsOption 1Option 2
first15,64316,519
216,53914.515
314.3916,592
416,53614.506
516.915,391
medium16.001615.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/

Chia sẻ bài viết ngay

Nguồn bài viết : Viblo