There was a time, back in the old Symbian and Windows CE days, when app sizes, were only measured in kilobytes. Especially when it comes to app updates, which, ideally, should be smaller than the original app download itself. Taking up the cause for smaller file sizes, Google has revealed a new technique to keep updates to a minimum, reducing sizes by 65% on average.
In an ideal setting, updates shouldn’t be as large as the full app, since it should only change what was really changed, not download the whole thing again. In reality, things are a bit tricky.
The new technique is being called “File-by-File patching” and it does exactly that. Android apps are packaged into APKs, which are technically just ZIP files with special features. The problem with compressed packages like this is changing even a small part of just one file in the set can lead to a huge difference in the signature of the compressed package. To get around this to reduce the file size, Android developers had to employ a few tactics and what looks like a rather complicated process.
Google Play Service uncompresses both old and new versions of the app and then computes the difference between the actual files in them rather than just the difference between the APKs. It then sends the device this patch, which is basically just a smaller file describing what has changed in between versions. To apply the patch on the device’s end, Android first checks if the original, older APK’s signature matches the canonical one on Google Play Store (i.e., it hasn’t been tampered with), uncompresses the APK, applies the patch only to the files that changed, and then compresses the files again into an APK, using the same compression settings that the developer used.