Tracking app update sizes
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?
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 apk_patch_size_estimator.py --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,
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.
This is useful for showing you raw APK content size differences, such as how much your DEX files or resources changed between versions, but does not currently show app update sizes as delivered by the Play Store or calculated by the APK patch size estimator.