Android Kaki

Build beautiful, usable products using required Components for Android.

App Measurement Metrics – Steady Monitoring App Measurement, Half 2 | by Akash Khunt | June 2023

picture taken by Choong Deng Xiang ABOVE depart

IN Half 1we mentioned the significance of constantly monitoring APK dimension and began implementing the Github Motion workflow the place the primary work is completed Make a construct for each the bottom department and the merge department. On this publish we’ll do the second job i.e. Generate dimension distinction report of the identical workflow.

Generate Python Script (to generate dimension distinction report)

The script itself might be damaged down into the next sections:

  • Setting
  • Create a dictionary – Part catalog for dimension mapping
  • Generate HTML Experiences – Use the dictionary generated above to generate readable HTML output in tabular format

setup stage – Setup section
  • Traces 2 & 3 – Right here we’re parsing arguments handed throughout script execution
  • Traces 5 & 6 – We append .apk suffix for the above parsed arguments
  • Line 9 – This location will rely upon the GHA runner you might be utilizing. This may be accomplished dynamically primarily based on working system checks.
  • Traces 15 & 16 – Right here we name get_apk_components perform that creates dictionary with class names (i.e. Native Libraries (arm64-v8a), Courses, Sources, and many others.) to dimension mapping.
  • Line 18 – Right here we name create_size_diff_html will generate an HTML report evaluating the dimensions distinction between completely different classes.

Create dictionary stage – Dictionary construct section

On this section, we’ll use apk_1_name & apk_2_name created in Setup section.

  • Traces 32–37 – Right here we outline a perform execute_command, whose sole accountability is to execute the shell command and return the decoded end result.
  • Traces 40–44 – Right here we replace ingredient dictionary worth (i.e. dimension) in case supplied key ie (class title) is already out there or add a brand new merchandise in case key absent.
  • Line 3 – Right here we construct apk analyzer command to get listing of all recordsdata bundled in apk together with their obtain dimension. In case you need to learn extra concerning the completely different arguments you possibly can move, you possibly can discuss with this. It took me some time to generate the right command 😅.
  • Line 5 – Right here we name execute_command with the command generated in Line 3. The output of this command will seem like under, the place every line incorporates obtain file dimension in bytes, “t” delimiter, & file title.
apk analyzer command output instance
  • Line 6 – Cut up files_with_size_string with newline character and retailer it in files_with_size_list.
  • Line 10 – Right here we begin looping by way of every merchandise contained in files_with_size_list.
  • Line 11 – Right here we additional break down every merchandise contained in files_with_size_list use ‘t’.
  • Line 14 – Right here we verify if the output from Line 11 ends in an inventory of precisely 2 objects (i.e. File Measurement & filename) And filename a minimum of 1 character lengthy. That is to filter out invalid entries.
  • Traces 18–27 – Right here we add/replace the worth of every dictionary entry (e.g. Native Libraries (arm64-v8a), Courses, Sources, and many others.) filename appropriate standards. NOTE: This step ought to be configured primarily based on the way you need to classify the dimensions distinction report.

We’ll run get_apk_components features for each apks and ends with component_1 & component_2 dictionary as talked about in setup stage.

Create HTML report stage – Generate HTML report stage

On this section, we’ll create an HTML desk that compares the dimensions of every dictionary entry.

  • Traces 25–31 – Right here we format the dimensions (of dictionary entries, not particular person recordsdata) from bytes to KB/MB. In case the dimensions is lower than KB then it’s thought of as 0KB.
  • Traces 34–37 – Based mostly on dimension (i.e. distinction in dimension of the identical kind of entry in each dictionaries), we add the indicator 🟢 (to scale back dimension) or 🔴 (to extend dimension).
  • Traces 40–43 – Calculate total apk obtain dimension utilizing apk analyzer request.
  • Traces 3–6 – Right here we add the HTML physique content material with some textual content and the desk row incorporates Ingredient, Base, unify & distinctive objects.
  • Traces 9–12 – Right here we iterate by way of the entries of component_1 & component_2 dictionary and add an entry to the desk row.
  • Traces 15 & 16 – Right here we name apk_size perform to generate obtain file dimension of each base and merge apks.
  • Line 18 – Add one ultimate entry to our distinction dimension desk that incorporates a comparability of the full obtain sizes between the bottom apk and the merge bundle.
  • Line 21 – We write the generated HTML apk_size_diff_report.html the file that we’ll add to be used within the ultimate work ie Add dimension distinction report as PR remark.

Ultimately, the entire situation will seem like under:

Python script to check dimension contributions from excessive degree elements

Word: It’s essential to put this script in .github/scripts/ listing to carry out the next work.

Because the apk dimension comparability script is now prepared, we will begin including a second job to the present workflow we created earlier.

Process 2: Generate dimension distinction report

Measurement Metrics workflow with solely size_diff_report job

To focus solely on this work, we have now omitted the top-level configuration in addition to the contents of construct job.

Traces 7–8 – Right here we have now recognized size_diff_report_file setting variable as we’ll use it on this job in addition to the subsequent one. On Line 17 we outline the earlier dependency construct work use demand config, it will make sure that this job will solely run if construct job accomplished efficiently.


  1. Examine the code
  2. Obtain high/merge apk that we uploaded in construct job
  3. Obtain base apk that we uploaded in construct job
  4. Execution the script will generate apk_size_diff_report.html doc.
  5. Add apk_size_diff_report.html to make use of within the subsequent job ie Add dimension distinction report as PR remark.

Process 3: Add dimension distinction report as PR remark

Measurement Metrics workflow with solely size_diff_report . job

To focus solely on this work, we have now omitted the top-level configuration in addition to the contents of each construct & size_diff_report job.

This would be the smallest in addition to the best of the three jobs as we’ll obtain the dimensions distinction report file after which use its contents so as to add PR feedback.

On Line 22 we outline the earlier dependency size_diff_report work use demand config, it will make sure that this job will solely run if size_diff_report job accomplished efficiently.


  1. Obtain apk_size_diff_report.html file that we created within the earlier job.
  2. Right here we first analyze the content material of apk_size_diff_report.html file right into a string after which add it as a PR remark to extend PR reviewers’ visibility into the affect of apk dimension.

The complete workflow file ought to seem like under:

Finishing the Dimension Metric Workflow

I hope your crew can even use this workflow (or perhaps an improved model ) as a part of your CI workflow that can assist you higher perceive how the modifications/options your have an effect on apk dimension.

John Wick: Chapter 4 (FREE) FULLMOVIE The Super Mario Bros Movie avatar 2 Where To Watch Creed 3 Free At Home Knock at the Cabin (2023) FullMovie Where To Watch Ant-Man 3 and the Wasp: Quantumania Cocaine Bear 2023 (FullMovie) Scream 6 Full Movie
Updated: June 21, 2023 — 1:39 am

Leave a Reply

Your email address will not be published. Required fields are marked * © 2023 Android kaki