Customizable Delivery Options in Android

Kayvan Kaseb
Software Development
8 min readApr 7, 2020
Customizable Delivery Options in Android, photo by Kayvan Kaseb

As a matter of fact, Android App Bundle can be able to solve some previous problems in Android development by providing a way for developers to create a single package from within Android Studio, and have custom APK files automatically generated by Google Play for each individual supported configuration. Besides, after introducing Android App Bundle, a number of developers have used this approach to optimize delivery. This essay aims to discuss some options for customizable delivery in Android development.

Overview

Recently, after introducing Android App Bundle, a number of developers have used this approach to optimize delivery. This includes some of the most popular apps on Play like YouTube, and they observe incredible size changes, that range from around 10% to 60% decreases in comparison with delivering a normal APK. The introduction of the App bundle gives you an opportunity for utilizing new delivery features in Android, which would not have been possible in the past. By using App Bundle, we can build delivery that optimizes all aspects of your app serving from which part of the app to serve, to whom and when. Additionally, some customizable delivery options give you a chance to control of how your app is delivered. Some products can illustrates the concept of customizable delivery in Android at the moment that are mentioned as follows:

  1. In-app updates
  2. Conditional Delivery
  3. On-demand delivery and Dynamic Feature
  4. Asset delivery for games

Android App Bundle

As you know, the App Bundle is a new publishing format that replaces the traditional monolithic APK; however, the App Bundle is not installed directly. In contrast, Google Play generates APKs optimized for specific devices from the single bundle upload. These APKs are much more smaller than a single APK. In addition, the single upload provides a much simpler developer experience than uploading multiple APKs. Therefore, the smaller download size is achieved by delivering just only the resources from the app that the specific devices need. By using App bundle, only the selected languages, densities, and CPU architectures are delivered. As a result, a smaller install space on the device and a faster download could be reached via this option. Studies has showed that the App Bundle causes 20% decrease in app size on average. This leads to faster downloads, which leads to an 11% in install successes due to fewer chances for failing the process of downloads. Besides, because less storage space is used, it causes a reduction in uninstalls. Thus, there are more than 80,000 apps have moved over to the App bundle at present. These Android apps are publishing a single bundle, and relying on Google Play to deliver smaller APKs to particular devices tailored for them.

An Android App Bundle is a file with the .aab file extension, which you upload to Google Play. In fact, App bundles are signed binaries, which organize your app’s code and resources into modules, as indicated in below figure:

Android App Bundle from Google Android developer documents

In-app updates

Fundamentally, keeping your Android app up-to-date on your users’ devices, enables them to use advanced features of your app. Furthermore, users can benefit from performance enhancements and bug fixes appropriately. In essence, in-app updates is a Play Core library feature, which introduces an advanced request flow to active users to update your app immediately. In-app update approach works just only with devices running Android 5.0 or higher, and needs you to use Play Core library 1.5.0 or higher versions. Currently, in-app updates give you a way to trigger updates of your app directly from your app. This means it gives you control over the right contextual moment to start an update, when keeping the user in the app without any additional risks to users. Basically, in-app updates can classify in two flavors as below:

1.Immediate: it triggers the updates right away, and it needs minimal integration, because Play manages User Experience during the update. In other words, a full screen user experience, which needs the user to update and restart the app in order to use the app. This approach is best for some situations, where an update is vital for continued use of the app. After a user accepts a prompt update, Google Play manages the future process such as installation and restart the app.

2. Flexible: it lets you that customize the user experience during the user update. This needs more consideration and design work, but it is eventually much more customizable approach. Once the user has accepted, control is returned immediately back to the app, and the user can continue to use the app while the update is being downloaded. Eventually, when the update is ready, Play will inform the app again, and the app can accomplish a task appropriately. So, the flexible in-app update flow provides the developer the opportunity to customize the experience during the in-app update. Before doing the update operation, you must check if an update is available or not. This is done because if the update is not available, we have to ask the user to update the app. So, it will have a negative impression on the user. For this reason, we should first check, if an update is available or not. To check for an update, you can use the AppUpdateManager. We acquire an instance of an appUpdateManager from Play Core library. This is an object that allows you interact with the in-app update API.

val appUpdateManager = AppUpdateManagerFactory.create(context)


val appUpdateInfoTask = appUpdateManager.appUpdateInfo

appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
) {
// Request the update.
}
}

Conditional delivery

Traditionally, all your codes and app contents are always serve to all users. However, you have features that are simply not applicable to some of the users or the some of the devices in some cases. So, Conditional Delivery enables you to control which part of your app would be served to which users. With conditional delivery, you can set a set of conditions under which a feature module would be delivered, and otherwise will be left out. This allows you exclude a certain part of your app from some of the Android devices, and avoid loading your app with irrelevant features to the devices, which it is installed on. This means it optimizes download size and on-device footprint of your app.

Conditional delivery lets you to set certain device configuration requirements for dynamic feature modules to be downloaded automatically during app install. For instance, you can configure a dynamic feature module that includes functionality for augmented reality to be available at app install for just only devices that provide AR.

There are three types of conditions for conditional delivery:

  1. Device hardware and software features: You can be able to deliver your module only to devices that support a certain feature like a VR headset.

2. Specific Country: You can have a module included only for specific countries.

3. SDK version: You can be able to restrict a module by minimum SDK version by targeting only Android devices above a certain version.

Configuring conditional delivery is simple. Once you have extracted the feature into the module, the only change needed is adding installation instructions to the android manifest XML. The newly-introduces install time elements let you to specify conditions for delivery. You can mention conditions for device, user country, and min SDK. For instance, delivery is conditioned by device feature and min SDK. Thus, conditions could be combined.

<dist:delivery>
<dist:install-time>
<dist:conditions>
<dist:device-feature dist:name ="android.hardware.camera.ar"/>
<dist:min-sdk dist:value="24"/>
</dist:conditions>
</dist:install-time>
</dist:delivery>

The user country condition lets you exclude or include a module in specific countries, and you can also specify more than one country. In below example, the module will be deployed only to United States and Britain:

<dist:user-countries dist:exclude="false">

<dist:country dist:code="US"/>
<dist:country dist:code="UK"/>
</dist:user-countries>

On-demand delivery and Dynamic feature

Even if your modules are conditional at install time, but you simply do not know whether a module is relevant for a user or not in some situations. Therefore, on-demand delivery allows you install and remove specific features and modules during the lifetime of an app based on user behavior inside the app. As a matter of fact, Dynamic feature modules let you to separate certain features and resources from the base module of your app, and include them in your app bundle. Through Dynamic Delivery, users can later download, and install those components on demand after they have already installed the base APK of your app. For instance, a feature of an app has been used only by a small numbers of their users, and is rarely used more than once by an individual user. However, it is a relatively large component of this app. As a result, it is a perfect candidate for being a feature module delivered on demand.

Dependency tree for an app served using split APKs from Google Dynamic Delivery Tutorial

The main goals of dynamic delivery are to diminish the amount of time and bandwidth it takes to install an app from the Google Play Store, while also ensuring that only the minimum storage space is used by the app once it is installed. Dynamic feature modules (as on-demand modules) allow the various features, which create an Android app to be packaged into separate modules that are only downloaded and installed onto the device when they are required by the user.

Asset delivery for games

In essence, there are a massive amount of contents for some games that comes from codes and assets in order to start playing. A number of developers are using CDN solutions; however this makes negative effects on User Experience, In addition, the CDN cannot optimize its content and delivery to the requesting clients. So, you have to serve all assets to all users, regardless if they will ever use them. Another main downside of using a CDN is that you cannot rely on auto updates of assets. As a result, this leads to have long waits for updating resources after the game is already installed.

By extending the App Bundle format to include game assets, asset pack for games is introduced. In contrast to feature modules, asset packs are composed of assets only, with no executable code, and can be extremely large. Asset packs will be packaged in the App Bundle alongside your game binary; therefore, you can be able to publish a single artifact to Play includes everything your game needs. Additionally, you can be rely on Play to keep your assets up-to-date, just like it currently does with your game binary, and similarly to the flexibility you have with feature modules. In short, you will be able to customize asset delivery according to your game needs.

Play Asset Delivery is Google Play’s solution for delivering large amounts of game assets by extending the Android App Bundles format. Play Asset Delivery offers developers flexible delivery methods and high performance. It has a small API footprint, and is free to use.

Play Asset Delivery uses asset packs, which are composed of assets without executable codes. By using Dynamic Delivery, you can customize how and when each asset pack is downloaded onto a device according to three delivery modes: install-time, fast-follow, and on-demand.

In conclusion, Android App Bundles tackle some previous issues in Android by providing a way for developers to create a single package from within Android Studio, and have custom APK files automatically generated by Google Play for each individual supported configuration. Also, after introducing Android App Bundle, a number of developers have used this approach to optimize delivery in their apps. In this article, some options for customizable delivery in Android development were discussed based on Google resources.

--

--

Kayvan Kaseb
Software Development

Senior Android Developer, Technical Writer, Researcher, Artist, Founder of PURE SOFTWARE YAZILIM LİMİTED ŞİRKETİ https://www.linkedin.com/in/kayvan-kaseb