Support dynamic delivery solution in SDK
IAPMiniProgram SDK designs a unified module dynamic delivery solution that allows the super app to download and install the required modules per your requirements to run your applications.
For example, in order to enhance the performance and rendering capability of mini programs, MYWeb module dynamic feature is supported. For example, Google map SDK dynamic integration is supported.
Prerequisite
Make sure the following dynamic module names are used correctly according to the different features:
Feature | Module name |
| |
|
Step 1. Create the dynamic module
- In your project, click Create new module > Dynamic Feature to start creating a new module. (see the following figure).
- Choose the Base Application Module properly.
- Fill in the module name correctly according to the different features.
- For MYWeb feature


- Fill in the Module title according to the different features.
- For MYWeb feature, by default, "MyWeb Dynamic Feature" is used .

- For Google Maps SDK integration, you can directly choose the "Map Dynamic Feature".

- Note: In the Install-time inclusion drop-down list, choose (on-deman only).
- Click Finish to finish creating the module.
Step 2. Confirm the correctness of the AndroidManifest file
The default configurations in the AndroidManifest file are generated by the system. You need to check and confirm the correctness of the file.
Note: change the dist:title according to the different features.
Feature | Module name |
| |
|
Code sample:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution">
<dist:module
dist:instant="false"
dist:title="@string/title_mywebdynamicfeature">
<dist:delivery>
<dist:on-demand />
</dist:delivery>
<dist:fusing dist:include="true" />
</dist:module>
</manifest>Step 3. Confirm the dynamic repository is imported into the main module
- In the build.gradle file of the project app, the system generates the following code by default according to the different features. This is because that you choose the Base Application Module in the previous Step 1.
- For MYWeb feature
android {
dynamicFeatures = [':mywebdynamicfeature']
}- For Google Maps SDK integration
android {
dynamicFeatures = [':mapdynamicfeature']
}- In order to make the dynamic module take effects, must add the following codes in the build.gradle file:
android {
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
}- In the AndroidManifest.xml file of the project app, add the following code according to the different features.
- For MYWeb feature
<meta-data
android:name="com.alibaba.griver.dynamic.modules"
android:value="mywebdynamicfeature" />- For Google Maps SDK integration
<meta-data
android:name="com.alibaba.griver.dynamic.modules"
android:value="mapdynamicfeature" />Step 4. Import the dependency to support the dynamic feature
Import the dependency in the following files:
- In the build.gradle file of the project app, add the following codes to import the
iapminiprogram-dynamic-featuredependency.
Note: Check the latestiapminiprogram_versionversion in the Android Release Notes.
dependencies {
implementation "com.alipay.plus.android:iapminiprogram-dynamic-feature:${iapminiprogram_version}"
}- In the build.gradle file of the dynamic module, add the following codes according to the different features.
- For MYWeb feature, import the
iapminiprogram-mywebdependency.
dependencies {
implementation "com.alipay.plus.android:iapminiprogram-myweb:${iapminiprogram_version}"
}- For Google Maps SDK integration, import the
iapminiprogram-gmultimapdependency.
dependencies {
implementation "com.alipay.plus.android:iapminiprogram-gmultimap:${iapminiprogram_version}"
}Step 5. Configure to use the SplitCompat tool
In order to use the SplitCompat tool, need to finish the following configurations:
- In the build.gradle file of the project app, add the following codes to import dependencies accordingly:
// In your app’s build.gradle file:
...
dependencies {
// This dependency is downloaded from the Google’s Maven repository.
// So, make sure you also include that repository in your project's build.gradle file.
implementation 'com.google.android.play:feature-delivery:2.1.0'
// For Kotlin users, also add the Kotlin extensions library for Play Feature Delivery:
implementation 'com.google.android.play:feature-delivery-ktx:2.1.0'
...
}- Turn on the
SplitCompatin your application based on the following different cases.
Case | To do |
If you have a customized application | You need to add the following codes in the attachBaseContext() function of your current application: copy |
If you do not have a customized application | You need to define a new application as the following codes, which inherits copy |
Step 6. (Optional, for MYWeb only) Optimize the MyWeb dynamic download experience
If you want to optimize the MYWeb dynamic download experience, for example whether a custom dialog box is displayed to explain the reason for downloading, knowing the download status, and so on, to achieve these experiences, use the GriverDynamicFeatureExtension interface.