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 modulesper your requirements to run your application.
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.
Integration ways
For the following features/modules, you can choose one of the following integrations ways.
Note: It is highly recommended to use the Dynamic integration way.
Integrations way | Description |
The direct dependency is in the project, which is packaged into the APK along with the project. | |
Based on Google Dynamic Feature capability, download the APK from the Google Play Store when the application is opened. This can reduce the APK size when downloading and improve users' downloading experience. |
Static integration
For MYWeb Feature, in the build.gradle file of the project app, add the iapminiprogram-myweb depedency as the following code sample:
Note: Obtain the latest iapminiprogram_version version in the Android Release Notes.
dependencies {
implementation "com.alipay.plus.android:iapminiprogram-myweb:{iapminiprogram_version}"
}Dynamic integration
Prerequisite
Make sure the following dynamic module names are used correctly according to the different features:
Feature | Module name |
MYWeb feature |
|
|
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.
- By default, "MyWeb Dynamic Feature" is used for MYWeb feature.

- 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:titleaccording to the different features.
Feature | Module name |
MYWeb feature | "@string/title_mywebdynamicfeature" |
Google Maps SDK integration | "@string/title_mapdynamicfeature" |
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']
}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" /><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.
Next steps
Configure the authorization code
After you integrate the MyWeb module/dynamic feature:
- You need to provide the package name of your application and SHA256 signature.
We will provide you with the authorization code for MYWeb accordingly. - Then in the Android project, you need to configure the authorization code for
releaseanddebugin the AndroidManifest.xml file and thebuild.gradlefile. Refer to the following code sample:
- AndroidManifest.xml file:
<application>
<!-- configure ${activation_code} placeholder -->
<meta-data
android:name="com.alipay.myweb.init.ACTIVATION_CODES"
android:value="${activation_code}"/>
</application>- build.gradle file:
android {
buildTypes {
release {
/* configure the Release activation_code */
manifestPlaceholders = [
activation_code: "mg*****...="
]
}
debug {
/* configure the Debug activation_code*/
manifestPlaceholders = [
activation_code: "4X*****...=="
]
}
}
}Note:
- If the authorization code is incorrect, MYWeb module/dynamic feature will not be enabled and will automatically fall back to the system web view (
webview). - If you have multiple signatures and package names, need to configure the authorization code based on the different environment accordingly.
FAQ
For troubleshooting, refer to the Android SDK FAQ.