Spotify Ruler Helps Optimize Android App Size
Ruler is an open-source tool developed by Spotify to analyze Android apps and guide developers to identify which of their components contribute the most to app size.
The importance of optimizing app size to increase install conversion rates cannot be understated, says former Googler Sam Tolomei. Indeed, a study conducted at Google for the years 2013-2017 showed that for every 6MB increase in app size, the conversion rate of installs decreased by 1%. Large APK files have also been shown to increase the rate of installation failures, either due to the time or cost associated with downloading, or due to connectivity issues. The picture deteriorates if we consider that a large percentage of users do not have access to WiFi or to a large free storage capacity.
Since Android apps are currently distributed as AAB, in order to estimate an APK size for a given device configuration, Ruler relies on the same approach used by Google to generate APKs from ‘AAB with Google’s Bundletool. Once the APK is generated, Ruler will analyze it.
We analyze this APK to see what files actually end up in the app and how much space those files take up, leveraging apkanalyzer to ensure the numbers reported by Ruler remain consistent with those analyzed by Android Studio and ensuring that we measure app size after any optimization done. by another process.
The next step in the process is to map each of the application’s files 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 into a DevOps pipeline and executed, as Spotify does, on each pull request to detect any regression as soon as possible.
Spotify says it has been using Ruler internally for over six months with an overall reduction in app size of around 9%. It’s worth noting that the Spotify app is rather complex, with over 1,000 Gradle modules and hundreds of third-party dependencies, so your mileage may vary.