Dynamic Delivery

Google Play’s app serving model, called Dynamic Delivery, uses Android App Bundles to generate and serve optimized APKs for each user’s device configuration, so users download only the code and resources they need to run your app. You no longer have to build, sign, and manage multiple APKs to support different devices, and users get smaller, more optimized downloads.


Dynamic Delivery with split APKs

A fundamental component of Dynamic Delivery is the split APK mechanism available on Android 5.0 (API level 21) and higher. Split APKs are very similar to regular APKs—they include compiled DEX bytecode, resources, and an Android manifest. However, the Android platform is able to treat multiple installed split APKs as a single app. That is, you can install multiple split APKs that have access to common code and resources, and appear as one installed app on the device.

For example, one split APK may include the code and resources for an additional feature that only a few of your users need, while another split APK includes resources for only a specific language or screen density. Each of these split APKs is downloaded and installed when the user requests it or it’s required by the device.

The base APK is at the head of the tree with dynamic feature APKs having
        a dependency on it. Configuration APKs, which include device
        configuration-specific code and resources for the base and each dynamic
        feature APK, form the leaf nodes of the dependency tree.

The following describes the different types of APKs that may be installed together on a device to form your full app experience. 

  • Base APK: This APK contains code and resources that all other split APKs can access and provides the basic functionality for your app. When a user requests to download your app, this APK is downloaded and installed first. That’s because only the base APK’s manifest contains a full declaration of your app’s services, content providers, permissions, platform version requirements, and dependencies on system features. Google Play generates the base APK for your app from your project’s app (or base) module. If you are concerned with reducing your app’s initial download size, it’s important to keep in mind that all code and resources included in this module are included in your app’s base APK.
  • Configuration APKs: Each of these APKs includes native libraries and resources for a specific screen density, CPU architecture, or language. When a user downloads your app, their device downloads and installs only the configuration APKs that target their device. Each configuration APK is a dependency of either a base APK or dynamic feature APK. That is, they are downloaded and installed along with the APK they provide code and resources for. Unlike the base and dynamic feature modules, you don’t create a separate module for configuration APKs. If you use standard practices to organize alternative, configuration-specific resources for your base and dynamic feature modules, Google Play automatically generates configuration APKs for you.
  • Dynamic feature APKs: Each of these APKs contains code and resources for a feature of your app that you modularize using dynamic feature modules. Through Dynamic Delivery, you can then customize how and when that feature is downloaded onto a device. For example, using the Play Core Library, dynamic APKs may be installed on demand after the base APK is installed on the device to provide additional functionality to the user. Consider a chat app that downloads and installs the ability to capture and send photos only when the user requests to use that functionality. Because dynamic features may not be available at install time, you should include any common code and resources in the base APK. That is, your dynamic feature should assume that code and resources of only the base APK are available at install time. Google Play generates dynamic feature APKs for your app from your project’s dynamic feature modules.

Creating a dynamic feature module

To add a dynamic feature module to your app project using Android Studio(3.2 Canary 14+)

Note : Before creating a dynamic module, you have to create you app bundle.

1. Select File > New > New Module from the menu bar. In the Create New Module dialog, select Dynamic Feature Module and click Next.

2. On the Configure your new module screen, give your module a name.

3. On the Configure your new module screen, specify the module title.

  • Select the on-demand only in install-time inclusion if you want the module to be available for on demand downloads.
  • Check the Fusing box if you want this module to be available to devices running Android 4.4 (API level 20) and lower and include it in multi-APKs.

References:
https://developer.android.com/studio/projects/dynamic-delivery
https://medium.com/mindorks/dynamic-feature-modules-the-future-4bee124c0f1

Leave a comment