All Products
Search
Document Center

SuperApp:Integrate a miniapp container into a native app

Last Updated:Dec 30, 2025

SuperApp allows you to integrate the WindVane or uni-app miniapp container into a native app. This topic describes how to integrate a miniapp container into an Android app.

Prerequisites

  • The AccessKey, SecretKey, and App Code of a native app are obtained. For more information, see the Configure an app topic in the Application Open Platform (for platform operators) chapter of the User Guide.

  • The ID of a miniapp is obtained. For more information, see Create a miniapp.

  • The domain name of Application Open Platform is obtained. The domain name of the demo environment is poc.superapp-intl.com.

Step 1: Add the Maven repository

In the build.gradle file located in the project root directory, add the Maven repository.

Note

SDKs for miniapp containers are available in the Maven repository deployed in Apsara Stack. For information about the actual repository URL, account, and password, contact the O&M engineer.

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven {
            url 'http://nexus-ce.xxx.com/repository/maven-public/'
            credentials {
                username = '${username}'
                password = '${password}'
            }
        }
    }
}

Step 2: Add dependencies

In the build.gradle file of the app project, add the dependencies for the miniapp container.

dependencies{
  // The basic SDK for the miniapp container. This dependency is required for both WindVane and uni-app.
  implementation 'com.aliyun.emas.suite.core:servicebus:1.0.0'
  api "com.aliyun.emas.suite.foundation:mini-app-adapter:1.3.0"
  // The SDK for the WindVane miniapp container. If you want to integrate the WindVane miniapp container into the app, include this dependency. 
  implementation "com.aliyun.emas.suite.foundation:windvane-mini-app:1.3.2"
  // The SDK for the uni-app miniapp container. If you want to integrate the uni-app miniapp container into the app, include this dependency. 
  implementation "com.aliyun.emas.suite.foundation:uniapp-mini-app:1.3.0"
}
Important

If the project uses AndroidX dependencies, make sure that the gradle.properties file in the project root directory contains the following configurations:

android.useAndroidX=true
android.enableJetifier=true

Step 3: Initialize the container

You must initialize the miniapp container before you can use it.

MiniAppInitConfig config = new MiniAppInitConfig.Builder()
  .setUseWindVane(true) // Configure this method for a WindVane miniapp.
  .setUseUniApp(true)  // Configure this method for a uni-app miniapp.
  .setAccessKey("ZXZ****")  // Obtain the AccessKey from Application Open Platform.
  .setSecretKey("3PNJxKtf7/eqUohlG3bI****")  // Obtain the SecretKey from Application Open Platform.
  .setHost("emas.example.com")// Specify the domain name of Application Open Platform. The value in this sample code is provided for reference only. The domain name of the demo environment is emas-publish-intl.emas-poc.com. 
  .setAppCode("161160300555671164****")  // Obtain the App Code from Application Open Platform.
  .build();
IMiniAppService miniAppService = new MiniAppService();
miniAppService.initialize(application, config);
ServiceManager.getInstance().registerService(IMiniAppService.class.getName(), miniAppService);

// The following code provides an example of initialization configurations for the WindVane miniapp container. If you want to integrate the WindVane miniapp container into the app, include the configurations. 
WVCamera.registerUploadService(CustomWVUploadService.class);

Step 4: Obfuscations configuration

1. Windvine obfuscation configuration

If the host app has enabled obfuscation, the following obfuscation configurations need to be added.

-keepclassmembers class android.taobao.windvane.jsbridge.api.WVBase
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVBattery
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVBluetooth
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVCamera
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVContacts
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVCookie
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVFile
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVImage
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVLocation
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVMotion
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVNativeDetector
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVNetwork
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVNotification
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVPrefetch
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVReporter
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVScreen
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVScreenCapture
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVSystem
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVUI
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVUIDialog
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVUIToast
-keepclassmembers class android.taobao.windvane.jsbridge.api.WVVideo
-keepclassmembers class com.emas.hybrid.api.scan.WVScan
-keepclassmembers class com.emas.hybrid.api.call.EHApiCall
-keepclassmembers class com.emas.hybrid.api.storage.EHApiStorage
-keepclassmembers class android.taobao.windvane.standardmodal.WVStandardEventCenter
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.EHApiNavigator
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVAuthorize
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVDialog
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVGetAuthorizeSetting
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVMiniApp
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVMiniAppVersion
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVMiniPageEvent
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVNavigationBar
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVUIActionSheet
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVUIDatePicker
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVUser
-keepclassmembers class com.alibaba.module.android.mini.app.windvane.plugin.WVUserAuthorize
-keepclassmembers class com.alibaba.plugin.android.mini.app.plugin.WVEventReportPlugin

2. Uni obfuscation configuration

If the uni mini app container is introduced, the following obfuscation configuration needs to be added, including obfuscation configurations currently provided by uni app.

-dontwarn
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose

#-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-dontoptimize

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class * extends io.dcloud.common.DHInterface.IPlugin
-keep public class * extends io.dcloud.common.DHInterface.IFeature
-keep public class * extends io.dcloud.common.DHInterface.IBoot
-keep public class * extends io.dcloud.common.DHInterface.IReflectAble

-keep class io.dcloud.** {*;}
-dontwarn io.dcloud.**
-dontwarn com.alibaba.**

-keep class vi.com.gdi.** {*;}
-keep class android.support.v4.** {*;}

-keepclasseswithmembers class io.dcloud.appstream.StreamAppManager {
    public protected <methods>;
}

-keep public class * extends io.dcloud.common.DHInterface.IReflectAble{
  public protected <methods>;
  public protected *;
}
-keep class **.R
-keep class **.R$* {
    public static <fields>;
}
-keep public class * extends io.dcloud.common.DHInterface.IJsInterface{
  public protected <methods>;
  public protected *;
}

-keepclasseswithmembers class io.dcloud.EntryProxy {
    <methods>;
}

-keep class * implements android.os.IInterface {
  <methods>;
}

-keepclasseswithmembers class *{
  public static java.lang.String getJsContent();
}

-keepclasseswithmembers class *{
  public static io.dcloud.share.AbsWebviewClient getWebviewClient(io.dcloud.share.ShareAuthorizeView);
}

-keepattributes Exceptions,InnerClasses,Signature,Deprecated, SourceFile,LineNumberTable,*Annotation*,EnclosingMethod

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keep public class * extends android.app.Application{
  public static <methods>;
  public *;
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
   public static <methods>;
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keep class dc.** {*;}
-keep class okio.**{*;}
-keep class org.apache.** {*;}
-keep class org.json.** {*;}
-keep class net.ossrs.** {*;}
-keep class android.** {*;}
-keep class com.facebook.**{*;}
-keep class com.bumptech.glide.**{*;}
-keep class com.alibaba.fastjson.**{*;}
-keep class com.sina.**{*;}
-keep class com.weibo.ssosdk.**{*;}
-keep class com.asus.**{*;}
-keep class com.bun.**{*;}
-keep class com.heytap.**{*;}
-keep class com.huawei.**{*;}
-keep class com.meizu.**{*;}
-keep class com.samsung.**{*;}
-keep class com.zui.**{*;}
-keep class com.amap.**{*;}
-keep class com.loc.**{*;}
-keep class com.autonavi.**{*;}
-keep class pl.droidsonroids.gif.**{*;}
-keep class com.tencent.**{*;}
-keep class com.baidu.**{*;}
-keep class com.iflytek.**{*;}
-keep class com.umeng.**{*;}
-keep class tv.**{*;}
-keep class master.**{*;}
-keep class uk.co.**{*;}
-keep class com.dmcbig.**{*;}
-dontwarn android.**
-dontwarn com.tencent.**

-keep class * implements com.taobao.weex.IWXObject{*;}
-keep public class * extends com.taobao.weex.common.WXModule{*;}


-keepattributes Signature

-dontwarn org.codehaus.mojo.**
-dontwarn org.apache.commons.**
-dontwarn com.amap.**
-dontwarn com.sina.weibo.sdk.**
-dontwarn com.alipay.**
-dontwarn com.lucan.ajtools.**
-dontwarn pl.droidsonroids.gif.**

-keep class com.taobao.weex.** { *; }
-keep class com.taobao.gcanvas.**{*;}
-dontwarn com.taobao.weex.**
-dontwarn com.taobao.gcanvas.**

#Getui
-dontwarn com.igexin.**
-keep class com.igexin.** { *; }
-keep class org.json.** { *; }

-keep class android.support.v4.app.NotificationCompat { *; }
-keep class android.support.v4.app.NotificationCompat$Builder { *; }
#Meizu
-keep class com.meizu.** { *; }
-dontwarn com.meizu.**
#Xiaomi
-keep class com.xiaomi.** { *; }
-dontwarn com.xiaomi.push.**
-keep class org.apache.thrift.** { *; }
#Huawei
-dontwarn com.huawei.hms.**
-keep class com.huawei.hms.** { *; }

-keep class com.huawei.android.** { *; }
-dontwarn com.huawei.android.**

-keep class com.hianalytics.android.** { *; }
-dontwarn com.hianalytics.android.**

-keep class com.huawei.updatesdk.** { *; }
-dontwarn com.huawei.updatesdk.**
#OPPO
-keep class com.coloros.mcssdk.** { *; }
-dontwarn com.coloros.mcssdk.**


#Amap
-keep class com.amap.api.location.**{*;}
-keep class com.amap.api.fence.**{*;}
-keep class com.loc.**{*;}

#Tencent X5--------------start-----------------------
-dontwarn dalvik.**
-dontwarn com.tencent.smtt.**
#-overloadaggressively
# ------------------ Keep LineNumbers and properties ---------------- #
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
# --------------------------------------------------------------------------
# Addidional for x5.sdk classes for apps
-keep class com.tencent.smtt.export.external.**{*;}
-keep class com.tencent.tbs.video.interfaces.IUserStateChangedListener {*;}
-keep class com.tencent.smtt.sdk.CacheManager {public *;}
-keep class com.tencent.smtt.sdk.CookieManager {public *;}
-keep class com.tencent.smtt.sdk.WebHistoryItem {public *;}
-keep class com.tencent.smtt.sdk.WebViewDatabase {public *;}
-keep class com.tencent.smtt.sdk.WebBackForwardList {public *;}
-keep public class com.tencent.smtt.sdk.WebView {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.WebView$HitTestResult {public static final <fields>;public java.lang.String getExtra();public int getType();}
-keep public class com.tencent.smtt.sdk.WebView$WebViewTransport {public <methods>;}
-keep public class com.tencent.smtt.sdk.WebView$PictureListener {public <fields>;public <methods>;}
-keepattributes InnerClasses
-keep public enum com.tencent.smtt.sdk.WebSettings$** {*;}
-keep public enum com.tencent.smtt.sdk.QbSdk$** {*;}
-keep public class com.tencent.smtt.sdk.WebSettings {public *;}

-keepattributes Signature
-keep public class com.tencent.smtt.sdk.ValueCallback {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.WebViewClient {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.DownloadListener {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.WebChromeClient {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.WebChromeClient$FileChooserParams {public <fields>;public <methods>;}
-keep class com.tencent.smtt.sdk.SystemWebChromeClient{public *;}
# 1. extension interfaces should be apparent
-keep public class com.tencent.smtt.export.external.extension.interfaces.* {public protected *;}

# 2. interfaces should be apparent
-keep public class com.tencent.smtt.export.external.interfaces.* {public protected *;}
-keep public class com.tencent.smtt.sdk.WebViewCallbackClient {public protected *;}
-keep public class com.tencent.smtt.sdk.WebStorage$QuotaUpdater {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.WebIconDatabase {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.WebStorage {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.DownloadListener {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.QbSdk {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.QbSdk$PreInitCallback {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.CookieSyncManager {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.Tbs* {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.utils.LogFileUtils {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.utils.TbsLog {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.utils.TbsLogClient {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.CookieSyncManager {public <fields>;public <methods>;}
# Added for game demos
-keep public class com.tencent.smtt.sdk.TBSGamePlayer {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.TBSGamePlayerClient* {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.TBSGamePlayerClientExtension {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.TBSGamePlayerService* {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.utils.Apn {public <fields>;public <methods>;}
-keep class com.tencent.smtt.** {*;}
# end
-keep public class com.tencent.smtt.export.external.extension.proxy.ProxyWebViewClientExtension {public <fields>;public <methods>;}
-keep class MTT.ThirdAppInfoNew {*;}
-keep class com.tencent.mtt.MttTraceEvent {*;}
# Game related
-keep public class com.tencent.smtt.gamesdk.* {public protected *;}
-keep public class com.tencent.smtt.sdk.TBSGameBooter {public <fields>;public <methods>;}
-keep public class com.tencent.smtt.sdk.TBSGameBaseActivity {public protected *;}
-keep public class com.tencent.smtt.sdk.TBSGameBaseActivityProxy {public protected *;}
-keep public class com.tencent.smtt.gamesdk.internal.TBSGameServiceClient {public *;}
#Tencent X5--------------end-----------------------

Development Environment Setup

Gradle Version : 6.7.1

Android Gradle Plugin Version : 4.2.2

JDK Version : 8

MinSdkVersion : 16

TargetSdkVersion : 30

Note

The aforementioned configuration serves as a recommended environment setup, which may require updates for compatibility with varying versions.

API reference

For more information, see API reference.