NIXsolutions: Spotify Opens Ruler Tool that Analyzes App Sizes

When installing apps from the Google Play Store, users generally prefer smaller apps. This may be due to limited storage space on the device or a limited channel, or some users simply prefer a faster installation. Spotify has released a tool called Ruler that it uses to measure and analyze the size of its Android apps to figure out how to make them smaller. The company has made this tool open and free for any developer who wants to use it.

NIXsolutions

Apps published on the Google Play Store are now usually downloaded as an Android App Bundle. When a user requests an app to install, the Google Play Store creates an optimized APK for the end user who installs the app. The Ruler mimics this process to create an APK that matches exactly what the end user should receive. Then, for each file, the Ruler captures two values:

  • Download Size: Bytes transferred over the network when the user downloads the application.
  • Install Size: The bytes that the file occupies on the device after the application is installed.

The Ruler can then scan the application and find a list of files inside and their sizes. It can also find all Gradle modules and dependencies that affect the app’s size. This creates a second list of all components and their contents. Combining both lists allows you to group all the files in an application by their source and determine how much each module and dependency contributes to the overall size of the application, explains Apptractor.

Spotify says the main Spotify app has over 1,000 Gradle modules and hundreds of third-party dependencies, and that Ruler has helped reduce app size by over 9% in the last six months. The company says it exports app size data once a day using the latest major build. It can use this data to track historical trends for the application as a whole, as well as individual modules and third-party dependencies. The impact of each pull request on app size is also analyzed so that early feedback can be provided to developers.

NIXSolutions notes that Ruler is written entirely in Kotlin, and to use it, all you have to do is apply the plugin to your Android project and run a single Gradle task. You can find out more on the project’s GitHub page.