Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Spotify's Ruler Helps Optimize Android App Size

Spotify's Ruler Helps Optimize Android App Size

This item in japanese

Ruler is an open-source tool developed at Spotify to analyze Android apps and guide developers in identifying which of their components contribute the most to the app size.

The importance of optimizing app size to increase install conversion rates cannot be underestimated, explains former Googler Sam Tolomei. Indeed, a study conducted at Google for the years 2013-2017 showed that for every 6 MB increase to an app size, the install conversion rate decreased by 1%. Large APK sizes were also shown to increase the rate of failed installs, either due to the time or cost associated with the download or to connectivity issues. The picture gets worse when one considers that a large percentage of users do not have access to WiFi nor to large free storage capacity.

Since Android apps are currently distributed as AABs, in oder to estimate an APK size for a given device configuration, Ruler relies on the same approach used by Google to generate APKs from AABs with Google's Bundletool. Once the APK is generated, Ruler will analyze it.

We analyze this APK to see which files actually end up in the app and how much space those files take up, leveraging apkanalyzer to ensure the numbers reported by Ruler stay consistent with those analyzed by Android Studio and guaranteeing we measure app size after any optimizations done by another process.

The next step in the process is mapping each of the files of the app to their parent component, based on an analysis of all Gradle modules and dependencies included in the project. This provides an estimate of the size contribution of each individual module and dependency. Ruler is also able to map each component to the team that owns it, based on a list of component owners.

The tool is ready to be integrated in a DevOps pipeline and run, as Spotify does, on each pull request to detect any regression as early as possible.

Spotify says they have been using Ruler internally for over six months with an overall reduction in their app size by approximately 9%. It shall be noted that the Spotify app is rather complex, with over 1,000 Gradle modules and hundreds of third-party dependencies, so your mileage may vary.

About the Author

Rate this Article