Android Kaki

Build beautiful, usable products using required Components for Android.

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

Akash Khunt

photograph taken by Chess Luke ABOVE go away

App dimension is without doubt one of the crucial metrics that have an effect on conversion charges. The bigger the app dimension, the decrease the conversion price.

Actually, Google has discovered a powerful correlation between APK dimension and set up conversion price, which claims that the set up conversion price drops 1% for each 6MB added to the APK dimension. – Taken from GetStream Weblog.

At any time when a staff tries to scale back apk dimension, the very first thing they do is measure the app dimension and contribute by excessive degree class (e.g. .dex recordsdata, assets, property, JNI libraries) , often executed by way of Apk Analyzer instruments (included with Android Studio). Then the subsequent step is to search for potential enhancements by inspecting the occupancy dimension of every of those classes. This course of often entails changing PNG to WEBP, utilizing proguard guidelines, utilizing vectors as an alternative of raster property and many others. In case you are attempting to scale back the dimensions of your apk and need to know all that may be executed then you possibly can learn this.

After ending the Measurement Discount train, what is commonly neglected/neglected is the fixed monitoring of the identical, which is what we’ll concentrate on on this put up. Many occasions groups optimize their apk dimension however after 8-10 months, they face bloat apk dimension drawback once more as a result of they do not monitor apk dimension constantly. Steady monitoring is beneficial as a result of it lets you seize the event part itself and never in later phases like testing (when you possibly can create a launch apk for the primary time) or launch. It additionally helps you to decide on any third get together SDK as there are lots of choices that may meet your wants. So on this put up we’ll take a look at how we will implement an answer that may assist us to constantly monitor the apk dimension.

Make a plot

To assist us maintain observe of apk dimension constantly, we’ll construct a Github Actions movement that may generate apk dimension diff report (utilizing customized python script) at any time when PR is raised after which add a remark to the PR, containing the dimensions distinction report. The tip end result will appear to be under:

Report dimension distinction feedback added by our workflow

The workflow is split into 3 jobs:

  • Generate builds for each base department and merge department (i.e. head department + base department)
  • Generate dimension distinction report (utilizing customized python script & Apk Analyzer device)
  • Add dimension distinction report as remark PR

construct configuration

This step appears quite simple, however there are some caveats as a result of we can not run “./gradlewssembleRelease” after which begin evaluating apk dimension. It is because after we generate apk it often accommodates libs/abis for all completely different supported architectures (e.g. x86_64, armeabi-v7a, arm64-v8a and many others) & assets for all all completely different densities (e.g. mdpi, hdpi, xdpi, and many others.).

However because the introduction Android App Bundle, at any time when Consumer installs apk by way of Play Retailer, Consumer will get very particular apk splits for the machine in use. This division contains base app bundle, configuration app bundle (structure & display screen density individually) and have module app bundle (dynamic if used). You’ll be able to learn extra about it This.

So step one is to change our construct script in order that it permits us to generate the goal apk resConfig (to pick out a single language for string assets), structure/abi, & density which is able to make the comparability straightforward to grasp.

Configuration for resConfig quite simple as proven within the gist under.

resConfig configuration

Right here we attempt to match resConfig attribute and set it to “en” (ie English). This may be supplied by “./gradlewssembleRelease -PresConfig=en” The place is the command?-P” prefix means it needs to be handled as a property.

Subsequent we’ll add configuration for break up abi.

abi config break up

Construct configuration for break up abi It is a bit difficult as a result of it entails extra steps. We’ve to allow splits first, then since all of the abis are included robotically we have to take away it first after which embody the one ones which might be wanted. The required Abi will be supplied by “./gradlewssembleRelease -PtargetAbi=arm64-v8a” request.

Density config break up

Construct configuration for density division similar to abi and it may be provided by way of “./gradlewssembleRelease -PtargetDensity=xxhdpi” request.

After including configuration for all 3 we will run “./gradlewssembleRelease -PtargetDensity=xxhdpi -PtargetAbi=arm64-v8a -PresConfig=enthis command will create an apk containing arm64-v8a abi, xxhdpi density assets and English string assets.

For the reason that construct configuration is now prepared, we will begin implementing step one in our workflow i.e. Generate builds for each the bottom department and the merge department. One further factor we might be doing on this work is to rename the apk generated with the brief SHA of the respective department’s HEAD commit, this can make it simpler to establish the apk as a result of we’ll add generated artifacts for later use.

To generate the brief SHA, we’ll use the next shell script.

Shell script to generate brief SHA from git commit HEAD

Observe: You could put this script in .github/scripts/ listing to carry out the next work.

Job 1: Create builds for each base and merge branches

Measurement Metrics workflow with solely construct job

To maintain this put up brief, I will not go into element on how Github Actions precisely work as a result of there are lots of assets accessible for a similar factor.

The above script runs at any time when PR is raised to any main, main, launch/*, options/* department (Traces 8–10). It additionally takes care of canceling the continued workflow with the assistance of concurrently config (Traces 4–6).

We’ve additionally specified output (IE base_short_sha & head_short_sha) in us construct job as a result of we’ll use them for the subsequent jobs.


  1. Take a look at the code utilizing base_ref (goal PR department)
  2. Setup JDK 17, will not be required if you’re utilizing AGP variations under 8.0.0
  3. Android SDK setup, additionally will not be required primarily based on SDK and AGP model your goal is utilizing
  4. Arrange cache to make subsequent jobs run sooner by caching all android class recordsdata, dependencies and sdk instruments recordsdata
  5. Create shorter github sha for base department – This might be used to rename apk generated from identical department
  6. Construct the discharge APK for the bottom department and rename it to match the brief SHA generated within the earlier step i.e. Step 5
  7. Add apk generated in Step 6 – We’ll obtain this apk in subsequent works and this additionally permits to obtain apk in case somebody wants it
  8. Take a look at the code utilizing head_ref
  9. Right here we merge the base_ref department to head_ref department to verify we’ve all the newest code current within the base department. That is executed to deal with instances the place the grasp department shouldn’t be up to date utilizing the bottom department and one thing has been added/faraway from the bottom department.
  10. Repeat step 5
  11. Repeat step 6
  12. Repeat step 7

As soon as this job completes efficiently we’ll get 2 apks generated and uploaded so we will use them in our subsequent job.

That is all for this text. Within the subsequent put up, we’ll do the subsequent work i.e. Generate dimension distinction report would contain making a customized python script utilizing Apk Analyzer device.

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: July 12, 2023 — 5:33 pm

Leave a Reply

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