SBM blog CTA mobile 1

Boost ops efficiency, drive revenue, & save big with omnichannel messaging

How to reduce your Android app size: managing SDK size with Emerge tools

Sendbird facts Header 1
May 29, 2024 • 5 min read
Teddy Choe
Android Software Engineer
SBM blog CTA mobile 1

Boost ops efficiency, drive revenue, & save big with omnichannel messaging

SBM blog CTA mobile 1

Boost ops efficiency, drive revenue, & save big with omnichannel messaging

Why should you reduce your App size?

When building an app, it is essential to minimize its size. A larger app size adversely affects the number of downloads and the user's storage. Even App Stores alert users if the app’s size is too large, discouraging app updates on cellular networks.

At Sendbird, we provide various chat, video, business messaging, and GenAI SDKs to customers worldwide. Our utmost priority is to build optimized SDKs that impact the user’s memory as little as possible.

With multiple teams working on the same SDK, we need to prevent the SDK's size from increasing in too large a proportion. Also, as a leader in communication APIs with thousands of customers already using our SDKs, we always need to consider any undesirable effects caused by our efforts to minimize the SDK size. Therefore, monitoring our SDK must be integral to our development process.

Android SDK Size difference using the Minify configuration

When measuring the size of the app and SDK, you should check whether you have `minify` enabled. Enabling `minify` reduces the size of the code by removing dead code and unused resources. It mainly performs three tasks: Shrink, Obfuscation, and Optimization.

What are Android SDK Shrink, Obfuscation, and Optimization?

  • Shrink removes dead code that is not used in the final app.

  • Obfuscation makes reverse engineering more difficult by abbreviating the names of symbols and reducing the amount of code.

  • Optimization eliminates duplicate codes and improves code efficiency.

If Minify is set to true when building, the R8 compiler performs the above tasks, such as shrinking, obfuscation, and optimization. If you use a limited number of features in the SDK, the final app will contain only the parts of the SDK code used instead of the whole SDK binary.

It is vital to measure the SDK's size with both minify enabled and disabled. To use minify, add MinifyEnabled=true in build.gradle. If you want to check the size, we recommend adding the don't shrink option. According to the reference, this can reduce the size difference.

Emerge build types

How to measure the Android SDK size:

It’s not possible to measure the size of your Android SDK directly. Instead, we need to make two APKs of the same app: one with the Android SDK and another without it. After building the two Android apps, we can find the difference between the two sizes. This will give you the actual size of the integrated Android SDK.

For size measurement, Android Studio provides its APK Analyzer. With the APK Analyzer, you can check the list of Dex files the app refers to. Inside the list of Dex files, you can find the package name for your SDK and see how much percentage of the total app’s download size is occupied.


Emerge android apk analyzer

However, the APK Analyzer makes it difficult to manually check the size of multiple SDKs. In addition, you will want to keep a history of previously analyzed files for future reference. Yet, keeping the entire archive of APKs for every release is difficult.

This is where Emerge Tools can come in handy. Using the Emerge Tools, you can upload your APK files and see an X-ray view of them with the size of each component. With such detailed analysis results, it is easy to check the ratio of each binary source.

Emerge tools

It’s also easy to keep track of the SDK sizes over time as the Emerge Tools automatically saves and shows trends of the app size over time. ✨

Emerge app size over time

How to continuously monitor your Android SDK size with GitHub Actions

Monitoring your Android SDK size is crucial when refactoring existing code to improve its size.

Thankfully, Emerge Tool supports various automation tools, such as Fastlane, Gradle Plugin, and GitHub Actions, which can be integrated into an existing CI/CD pipeline.

If the SDK size has been measured through automation, it is necessary to communicate this information to developers efficiently. The GitHub Pull Request Comment API allows you to generate a comment with the measured SDK size.

Emerge sdk size

This API can also be used within a GitHub Actions workflow. At Sendbird, it was used as follows:

Emerge api github actions

Emerge Tools also provides a GitHub App that uploads the analysis result to the associated PR. This makes it very easy to compare differences, and by going into the Detail view, you can also check the X-ray of these differences. We leveraged these features to include this logic in our automated workflow. To use Emerge's features, you need to install the Emerge GitHub App on your GitHub account, and the size change must exceed the Size Threshold set in the Emerge Dashboard. Detailed information can be found in the documentation.

Emerge builds decrease size

Additionally, teams using Slack can leverage Emerge to notify the size changes through Slack alerts.

Emerge size change alerts

The benefits of using Emerge Tools at Sendbird to monitor the Android SDK Size

Before integrating Emerge Tools into our workflow, we had to manually measure the SDK size and observe the contents of the binary artifact. This was a cumbersome task, and ensuring effective collaboration between many developers to keep the SDK size optimal was challenging. Many times significant increases in SDK size went unnoticed.

With the Emerge Tools, however, we can now easily measure the size of our SDK and observe components’ impact with the X-ray tool. Developers can now evaluate how much their Android SDK size will change after code modifications and check the size of the SDK automatically.


Ebook Grow background mobile

What are the preferred communication channels of modern customers?