At Google I/O 2018, the search giant introduced Android App Bundles, a new file type built to keep file size and complexity under control. The new file is meant to better serve the diverse spread of devices that run Android.
Traditionally, Android apps are distributed using a special file called an Android Package, which uses the file extension .apk. APKs are basically zip files containing all the bits and pieces the app needs, like the program code and the resource files (graphics, audio, language files, and so on). When a developer submits an app to Google Play, they upload an APK, which is then distributed by Google and downloaded when a user installs the app.
Go in depth: The great thing about Android is its incredibly varied ecosystem. The operating system supports a wide range of processing system architectures, screen sizes and densities, and languages. An APK can handle all of that, as well as localization information (both text and graphics) for any number of different countries, without much trouble, though it can create a challenge for developers.
Making an app that works on the tiniest smartphone and the biggest Android TV can create a seriously large file, making it inaccessible to a number of lower-end devices. To keep file sizes low, some developers create multiple APKs containing files for specific screen densities or processors. Developers can upload these different files to Google Play, and Google will push the relevant ones to a device when the user installs it.
The problem with that method is it makes for more complex builds — that’s where Android App Bundles come in. The new file format includes all your app’s compiled code and resources, but allows Google Play to generate and serve optimized APKs for each user’s device.
Since app bundles only send the relevant chunks to individual devices, the actual size of the APK can be much smaller. According to Google, popular apps like Twitter could shrink around 35 percent. In other cases this could be has high as 50 percent.
The total number of permutations for language packs, screen densities, and supported CPU architectures can grow very quickly. According to Twitter, its app can be delivered in one of 500 different combinations via Android App Bundles. Maintaining 500 separate APK files would be time consuming and costly. This way Twitter can build one bundle and let Google Play sort out all the different permutations.
How to create Android App Bundles
Android Studio has been updated to handle this new build process and can now build a signed Android App Bundle ready for upload to Google Play. An app bundle is different from an traditional APK in that you can’t deploy it directly to a device. It first needs go to the Play Store, where Google Play will then handle the bundle and deliver the necessary tailored APK to devices.
There is a new Build Bundle option in the Build menu, alongside the traditional Build APK option.
You can find more details about the internal structure of bundles on Google’s Build, deploy, and upload Android App Bundles page.
Now that bundles allow an app to be split into different chunks, the next logical progression is to offer functionality in chunks. If a user doesn’t need certain functionality, why download it? The example Google gives is of app that allows consumers to sell and purchase items over the web. Many users will only ever purchase and never sell, and the selling code will sit on the device wasting resources. With Dynamic Delivery, the selling functionality isn’t included in the base APK installed. When the user wants sell something, the app will download the extra code and resources needed.
Android App Bundles could be a game changer for app delivery and management. Not only will we be getting space-optimized apps, but the possibilities of Dynamic Delivery means functionality can be added to apps as needed.
Read next: Android Studio tutorial for beginners
What are your thoughts? Are Bundles a step in the right direction?