One of the biggest announcements at Google I/O 2018 for Android developers was App Bundle which is a new upload format for APK’s to Play Store that includes all our app’s compiled code and resources, but defers APK generation and signing to Google Play which makes apps radically smaller.
The trick here is that developers can now say which of their apps’ assets should be included for a given device so there’s no need to ship every visual asset for every screen size and support for every language to every user. That can result in install files that can sometimes be more than 50 percent smaller than before.
To enable this new feature, Google rearchitected its whole app serving stack. So while the standard APK format isn’t going to change, every user now essentially gets a somewhat personalised file when hitting the Install button in Google Play. It’s new app serving model, called Dynamic Delivery, then uses the app bundle to generate and serve optimised APKs for each user’s device configuration, so they download only the code and resources they need to run the app. Developers no longer have to build, sign, and manage multiple APKs to support different devices, and users get smaller, more optimised downloads.’
Google says it tested this service with some of its own apps, including the YouTube and Google apps. A couple of other companies also tested it; Microsoft, for example, saw a 23 percent file reduction for the LinkedIn app. Most of the hard work to enable this feature is handled by Google, but developers who want to make use of it do have to specify which assets and languages they want to ship to which users.
The benefits offered by App Bundle are:
- Dynamic Delivery : Google Play’s new app serving model, called Dynamic Delivery, uses your app bundle to generate and serve optimised APKs for each user’s device configuration, so they download only the code and resources they need to run the app. For example, you don’t need content for other languages if you have set English as your default language.
- No need to manually manage multiple APKs : You no longer have to build, sign, and manage multiple APKs to support different devices, and users get smaller, more optimised downloads.
- Dynamic Feature Module (Beta): These modules contain features and assets that you can decide not to include when users first download and install your app. Using the Play Core Library, your app can later request to download those modules as dynamic feature APKs. For example, video calling feature and camera filters can be downloaded later on demand.
- Reduced APK size : Using Split APK mechanism, Google Play can break up a large app into smaller, discrete packages that are installed on a user’s device as required. On average, apps published with app bundles are 20% smaller in size.
- Instant Run (Coming Soon) : You will soon be able to “instant enable” the Android App Bundle, so that users can launch modules instantly, from any link, and without installation. Regardless of whether you start by building an app bundle or Android Instant App, you’ll be ready for instant-enabled Android App Bundles when we roll this feature out to all developers.
Currently App bundle is available only in Canary Channel 3.2 of Android Studio and will be available in the stable version soon.
Build a signed app bundle for upload
Before you can upload your app bundle to the Play console you need to generate a signed app bundle. To generate a signed app bundle, proceed as follows:
- Select Build > Generate Signed Bundle/APK from the menu bar.
- In the Generate Signed Bundle or APK dialog, select Android App Bundle and click Next.
- In the Module dropdown menu, select the base module of the app you want to generate an app bundle for.
- Provide information for an existing key and keystore, or create a new one. This is the same type of key and keystore information you provide when building a signed APK.
- If you want Android Studio to also save your signing key as an encrypted file, check the box next to Export encrypted key. To be able to upload your app bundle and take advantage of Dynamic Delivery, you need to upload this encrypted file to the Play Console and enroll in app signing by Google Play.
- Click Next.
- Provide a Destination Folder for your app bundle, and select the Build Type and Flavors that you want to generate app bundles for.
- Click Finish.
After Android Studio finishes building your signed app bundle, you can either locate or analyze the app bundle by clicking on the appropriate option in the pop-up notification. You can read more about app bundles and other cool features on the Android Developers site