Dynamic Delivery for a Android apps

dynamic-delivery-for-a-android-apps
Image source: https://www.google.com/search?q=dynamic+feature+module+android&sca_esv=590257647&rlz=1C5CHFA_enUS1005US1005&tbm=isch&source=lnms&sa=X&ved=2ahUKEwj259bh1YqDAxWicWwGHajFCMoQ_AUoA3oECAEQBQ&biw=1718&bih=933&dpr=2#imgrc=6s2Tjm-u62f8iM

Need and Significance of Dynamic Delivery

App size is an important consideration for developers because it can affect user experience and conversion rate.
The size of your APK has an impact on how fast your app loads, how much memory it uses, and how much power it consumes.

A large app size can lead to slower download speeds, which can discourage users from installing or updating the app.

According to Google, app size has a negative correlation with conversion rates for apps with sizes below 100 MB.

Google says that for every 6 MB increase to an APK’s size, the install conversion rate decreases by 1%.

Therefore, Google Play enforces a compressed download size restriction of 200 MB or less for apps published with app bundles, however, it is recommended to reduce the app’s download size as much as possible.

For apps you publish to Google Play by uploading signed APKs, compressed downloads are restricted to 100 MB or less.

Apple also enforces similar guidelines for iOS Apps,

· Binary file size: The maximum size is 4 GB.

· Executable file size: Each file must be less than 60 MB.

· Total uncompressed size: The total size must be less than 4 billion bytes.

· Binary size limit for cellular download: The maximum size is 200 MB.

Certain android libraries when included in the apps, increase the app size by a significant amount, for instance, adding the following dependencies increases the APK size by 3MB,

com.google.ar:core:1.34.0

com.google.android.filament:filament-android:1.20.2

com.google.android.filament:gltfio-android:1.20.2

com.google.android.filament:filament-utils-android:1.20.2

Adding the following dependencies increases the APK size by 25MB,

org.tensorflow:tensorflow-lite:2.11.0

org.tensorflow:tensorflow-lite-gpu:2.11.0

org.tensorflow:tensorflow-lite-task-vision:2.11.0

Google Play’s app serving model, Dynamic delivery plays a crucial role in optimizing the size of your APK from Google Play store, which is needed to comply with Google Play policies and for user retention.

This makes dynamic delivery, a present and future trend for mobile apps.

Dynamic Delivery

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 need to build, sign, and manage multiple APKs to support different devices, and users get smaller, more optimized downloads.

For example, a user should not get x86 libs if the device architecture is armeabi.

Dynamic Delivery uses advanced capabilities of app bundles, allowing certain features of your app to be delivered conditionally or downloaded on demand, in order to optimize the app download size from the play store.

Users can later download and install the components on-demand after they’ve already installed the base APK of the app. As a result, the initial download size of your app is less and users don’t need to have unused code/feature in their devices.

You can also convert your independent modules/features (without these modules your app is functional) into dynamic feature modules which can be downloaded later. For example, if your app has a custom camera feature you can make it a dynamic module and users can download and install the custom camera on demand.

Dynamic Delivery can be used in the following scenarios –

  • When including dependencies like TensorFlow Lite or AR Core that increase the app download size by a significant amount. For example, the AR Core and Filament dependencies, when added, lead to an increase of 3MB in Android applications.
  • Another scenario where we can use dynamic delivery is when the feature is being used by a small portion of your users, but it is leading to a significant increase in the APK size. For example, consider a text messaging app with functionality that allows you to capture and send picture messages. But we know that only a small percentage of users send picture messages. It may make sense to include picture messaging as a downloadable dynamic feature module. That way, the initial app download is smaller for all users and only those users who send picture messages need to download that additional component.
  • Another situation where you can use dynamic delivery is when the feature depends on hardware and may not be available on your user’s device. For example, say you have an app with a feature that requires augmented reality functionality. Currently, not all devices have the hardware to support this. Instead of shipping this feature to all devices, you can target devices with augmented reality support. This way, only devices with augmented reality support will download the augmented reality feature. By targeting only those users who can use that feature, you’ll reduce your app’s download size. Users will only download features they can use on their device and ones they’ll need.

Dynamic Delivery with split APKs

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. The benefit of split APKs is the ability to break up a monolithic APK into smaller, discrete packages that are installed on a user’s device as required.

  • 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.
  • 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.
Base APK and Dynamic APKs
  • Dynamic Feature APKs : Each of these APKs contains code and resources for a feature of your app that is not required when your app is first installed. That is, 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. Thereby, reducing the initial app size, and improving the user experience.
Dynamic module in App bundle and Split APKs from Play store

Dynamic delivery is unavailable for devices without a dynamic delivery compatible app store (Google Play store) installed.

Types of Dynamic Delivery

There are 4 different delivery options that feature modules support and below are different examples of how they might be used to optimize the initial download size of the sample app –

Install-time delivery :

In this type of delivery, the module will be part of base.apk. This type of delivery is used for the module which will be visible to the user only once.

If the app has certain training activities which are only used once, you can include that feature in the app install, by default.

However, to reduce the installed size of the app, the app can request to delete the feature after the user has completed the training.

On-demand delivery :

With this type of delivery, the base.apk will not contain a feature module and therefore decreasing the base.apk size when a user downloads the app. In this situation, we can dynamically load our module based on the compatibility of the module or when the flow is required. This is the best delivery option for our Eyewear trail feature as it is based on the ARCore service which is supported on most Android N+ devices.

If there are an extremely small number of audience members who use a certain feature, we can ask the user to download the feature whenever he tries to use it.

Dynamic delivery from Play store to an already downloaded app.

Conditional delivery :

Allows you to specify certain user device requirements, such as hardware features, locale, and minimum API level to determine whether a modularized feature is downloaded at app install. Again, taking the example of the Augmented Reality module, we can just make it an install-time module with a condition APK with the Augmented Reality feature being included in the base.apk. There are other conditions like country, hardware requirements, etc. that we can also specify.

Instant delivery :

Google Play Instant allows users to interact with your app without needing to install the app on their device. Instead, they can experience your app through the “Try Now” button on the Google Play Store or a URL that you create. This form of delivering content makes it easier for you to increase engagement with your app.

In this blog, we’ll focus on on-demand delivery.

Prerequisites:

  • Enable App bundles: To use DFM, we need to enable App Bundles. The Dynamic features modules cannot be bundled with normal APK and require shifting to the new publishing format i.e. .aab

For more info on App Bundles, checkout the link below: https://developer.android.com/guide/app-bundle

  • Remove shrinkResources from app.gradle
  • Modular Codebase: The most important thing to ensure before converting any feature to DFM is to first have a modular codebase.

How to get started with on-demand dynamic delivery?

1- Having one Dynamic Module in the application — For building a dynamic module, one can follow the steps listed on android developers website. Key point to note here is that build.gradle would contain the following,

dynamicFeatures = [“:feature_dynamicModule1”]

2- Having more than 1 Dyamic Module in the application having different dependencies — The process would be same as above and the build.gradle would list both dynamic features.

dynamicFeatures = [“:feature_dynamicModule1”, “:feature_dynamicModule2”]

3- Having more than 1 Dyamic Module in the application having same dependency — In this case, one would come across the following error,

Caused by: org.gradle.api.GradleException: [:feature_dynamicModule1”, “:feature_dynamicModule2] all package the same library [org.tensorflow:tensorflow-lite-api;Capability: group=’org.tensorflow’, name=’tensorflow-lite-api’].

Multiple APKs packaging the same library can cause runtime errors.Placing each of the above libraries in its own dynamic feature and adding that feature as a dependency of modules requiring it will resolve this issue.Libraries that are always used together can be combined into a single feature module to be imported by their dependents. If a library is required by all feature modules it can be added to the base module instead.

In this case, the solution is to have one dynamic module that contains the listed dependency to be used by 2 dynamic/normal modules.

Limitations of Dynamic Delivery

However, there are some constraints and edge cases to keep in mind when using feature modules:

  • Installing 50 or more feature modules on a single device, via conditional or on-demand delivery, might lead to performance issues. Install-time modules, which are not configured as removable, are automatically included in the base module and only count as one feature module on each device.
  • Limit the number of modules you configure as removable for install-time delivery to 10 or fewer. Otherwise, the download and install time of your app might increase.
  • Only devices running Android 5.0 (API level 21) and higher support downloading and installing features on demand. To make your feature available to earlier versions of Android, enable Fusing when you create a feature module.
  • Enable SplitCompat, so that your app has access to downloaded feature modules that are delivered on demand.
  • Feature modules should not specify activities in their manifest with android:exported set to true. That’s because there’s no guarantee that the device has downloaded the feature module when another app tries to launch the activity. Additionally, your app should confirm that a feature is downloaded before trying to access its code and resources. To learn more, read Manage installed modules.
  • Because Play Feature Delivery requires you to publish your app using an app bundle, make sure that you’re aware of the app bundle known issues.

Conclusion

Dynamic delivery could play a big role in optimizing the size of your APK from Play store, so its worth learning and considering when developing new features.

Resources

1- https://developer.android.com/guide/playcore/feature-delivery


Dynamic Delivery for a Android apps was originally published in Google Developer Experts on Medium, where people are continuing the conversation by highlighting and responding to this story.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
redefine-product-marketing:-vladimir-nikolic’s-story-of-transformation-[video]

Redefine product marketing: Vladimir Nikolić’s story of transformation [Video]

Next Post
2025-quality-plant-of-the-year:-spectrum-custom-packaging

2025 Quality Plant of the Year: Spectrum Custom Packaging

Related Posts