Tracking app update sizes

New: support for File-by-File updates in the APK patch size estimator

Reducing APK size has been a hot topic during the past year. There are a lot of reasons why: whether you’re Building for Billions to reach users with less capable devices on costly and unreliable networks or you’re just trying to optimize your app, everyone benefits from smaller APK sizes, faster downloads and shorter install times.

There are different costs related to the size of your app:

  • Size of the file you upload to Google Play (raw APK Size)
  • Initial download size
  • On-device install size
  • Update download size

We released a lot of guides explaining how to reduce the initial and on-device APK sizes, including new documentation pages, my I/O talk and articles, which explain how to optimize resources, shrink code and tailor the delivery of your APKs to users’ devices using techniques such as Multi APK.

This is all great, but users will usually install your app once per device, then download regular updates through the Play Store, which is why optimizing for app update size is equally important.

Optimizing for app update sizes

The best part about making app updates smaller is that so much of it happens automatically. Thanks to improvements in the way Android Studio packages APKs to make subsequent builds as similar to each other as possible, the Play Store can calculate smaller delta updates. In addition, the introduction of new algorithms in the Play Store, such as the recent File-By-File patching, helps reduce app update sizes by 65% on average.

The important thing to remember is to not interfere with the mechanisms that we have in place in both Android Studio and Play.
If you use the newest (at least 2.2+) Android Studio/Android Gradle Plugin to build your release APK, and do not modify it afterwards, you should be good to go.
Don’t compress the APK using custom ZIP encoder settings and don’t use Zopfli to recompress your APK or you will miss out on the big savings that File-by-File updates bring.

Tracking APK and update sizes

Now that you know why and how to do the right thing, is there an easy way to track your APK size? It’s normal that you will make changes to your apps, fix bugs and introduce new features, adding assets and libraries in the process. How to predict how big the next update will be for your users?

Google Play showing update size

We surface this information in a few ways. Firstly, and this is something users will see too, Play Store displays download sizes on the application’s listing page on Android, which becomes the update size for users who already have your app installed.

APK patch size estimator

For developers it would be more ideal to be able to see that number before publishing, that’s why we’ve open sourced a tool called the APK patch size estimator.

It’s a command line tool, so you can either integrate it in your Continuous Integration server and parse the output to include in your reports, or invoke it manually by giving it two APKs like this:

python --old-file old.apk --new-file new.apk

Here’s an example of the output:

New APK size on disk: 18,271,850 bytes [17.4MB]
Estimated download size for new installs:
Full new APK (gzipped) size: 16,339,603 bytes [15.6MB]
Estimated download size for updates from the old APK, using Bsdiff:
Bsdiff patch (gzipped) size: 2,989,691 bytes [2.85MB]
Estimated download size for updates from the old APK,
using File-by-File:
File-by-File patch (gzipped) size: 1,912,751 bytes [1.82MB]

The APK patch size estimator implements the current compression and delta algorithms used by the Play Store and will give you estimates of the initial APK download size for new installs (it’s different than raw APK size because Play Store may apply additional compression), and delta patch download size. We’ve recently updated the tool to support the new File-by-File updates, so you get an estimate for that as well.

Why estimates and not exact numbers? The Play Store keeps evolving and we often test new compression methods that could potentially save data for our users. We aim to keep the APK patch size estimator up to date with any new methods once they are fully rolled out to production.

By the way, it’s worth mentioning that for developers who want to understand which parts of the app grew (or shrunk) in size between versions, there’s also an interactive “Compare with” tool available as part of the APK Analyzer in Android Studio.

In Android Studio 3.0 we have updated this tool to optionally show file-by-file update sizes.

Like what you read? Give Wojtek Kaliciński a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.