1. Overview
Dynamic feature is a module distribution mechanism implemented by Google Play using the advanced features of Android App Bundle. It allows you to conditionally distribute or download certain features of your superapp on demand. This not only enables flexible business expansion but also effectively reduces the size of the superapp's main package. This document explains how to use the Dynamic Feature mechanism to distribute Super App as A Service (SAS) on demand, thereby minimizing its impact on the superapp's main package size. Before you begin, it is recommended that you familiarize yourself with the Android App Bundle and thedynamic featuremechanism, as well as any related considerations. 2. Integration steps
2.1 Create your SAS dynamic feature module
The steps are as follows:
3. Consult Request an on demand module to implement the installation request for SAS dynamic feature module in the main package (app module). 5. Follow Handle state updates to manage installation status updates, such as displaying download progress to your users. 6. Consult Access modules to enable SplitCompat for the dynamic feature module. Note:
The SAS SDK has already been made compatible with SplitCompat, so you only need to focus on the components specific to your module.
2.2 Integrate SAS in the dynamic feature module
1. Follow the SDK Integration guide to integrate SAS into your dynamic feature module. Note that the SDK-related dependencies must be added to the dynamic feature module. 2. Add the resource dependency package to build.gradle in the app module.
dependencies {
implementation 'com.tencent.tcmpp.android:mini_core_res:{version}' // For version number, see Android SDK Updates. }
Note:
1. The version number of mini_core_res should match that of mini_core.
2. mini_core supports the Dynamic Feature mechanism starting from version 2.2.6, so please use version 2.2.6 or higher.
3. Create an entry component for your dynamic feature module to manage your mini program.
Note:
Remember to enable SplitCompat for your entry component. Refer to Access modules. 4. Access your entry component in the app module to launch your dynamic feature module.
Note:
Ensure that you only access the code within the dynamic feature module after the installation status has been updated to SplitInstallSessionStatus.INSTALLED.
2.3 Test the dynamic feature module installation
The dynamic feature module installation can be tested in two ways:
1. Upload a version through Google Play for online testing.
2.4 Extension library integration
Note:
1. If the extension library depends on other third-party libraries, such as Google Maps or Google Ads, you need to add these third-party library dependencies to the app module, not the dynamic feature module.
2. Always use the latest version of the extension library.
2.5 Download SAS dynamic feature demo
The demo demonstrates how to integrate SAS using the Dynamic Feature approach for your reference. You can find it here:
3. FAQs
1. Since the manifest of the dynamic feature module is merged into the base APK, any resources that need to be accessed in the manifest must be declared in the app module. For example, if an Activity in the dynamic feature module uses a custom theme, the definitions of those themes need to be extracted to the app module; otherwise, you may encounter compilation errors.
2. Similarly, if the dynamic feature module uses a ContentProvider, the ContentProvider code must be integrated into the app module; otherwise, you may face runtime errors.
3. If any third-party libraries used in the dynamic feature module do not support SplitCompat for their Activity components, you will need to integrate those third-party libraries into the app module to avoid potential runtime errors.
4. Under the app bundle mechanism, when users install the superapp, only the languages selected by the system are installed by default. If you want to support unselected languages within the superapp, you will need to download the corresponding language packs using SplitInstallManager. Refer to: Download additional language resources.