tencent cloud

All product documents
Tencent Cloud Super App as a Service
SDK Integration
Last updated: 2025-04-22 18:11:24
SDK Integration
Last updated: 2025-04-22 18:11:24
This guide will help developers quickly integrate a minimal functionality mini program SDK to enable mini program opening.

Integration process

1. Configure the online repository address

The configuration method depends on the Gradle plugin version used in your project.
For Gradle version earlier than 7.0, see Method 1.
For Gradle version 7.1 and later, see Method 2.
Method 1:For Gradle version earlier than 7.0
Add the following configurations to the project-level build.gradle file:
buildscript {
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32'
}
}

allprojects {
repositories {
maven {
url 'https://maven-dev.tcmppcloud.com/fHKFBbEjd/repository/maven-public/'
}
maven {
url 'https://tcmpp-work-maven.pkg.coding.net/repository/tcmpp/android'
}
}
}
Method 2:For Gradle version 7.1 and later
Add the following configurations to the project-level settings.gradle file.
pluginManagement {
repositories {
maven {
url 'https://maven-dev.tcmppcloud.com/fHKFBbEjd/repository/maven-public/'
}
maven {
url 'https://tcmpp-work-maven.pkg.coding.net/repository/tcmpp/android'
}
}
}
dependencyResolutionManagement {
repositories {
maven {
url 'https://maven-dev.tcmppcloud.com/fHKFBbEjd/repository/maven-public/'
}
maven {
url 'https://tcmpp-work-maven.pkg.coding.net/repository/tcmpp/android'
}
}
}

2. Kotlin plugin configuration

The configuration of the Kotlin plugin also depends on the version of the Gradle plugin used in your project.
Method 1:For Gradle version earlier than 7.0
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
Method 2:For Gradle version 7.1 and later
plugins {
id "org.jetbrains.kotlin.android"
id "org.jetbrains.kotlin.kapt"
}

3. Configure packagingOptions

Add the following configurations to the app-level build.gradle file.
android {
defaultConfig {
packagingOptions {
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/armeabi/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libmarsxlog.so'
pickFirst 'lib/armeabi/libmarsxlog.so'
pickFirst 'lib/armeabi-v7a/libmarsxlog.so'
pickFirst 'lib/arm64-v8a/libv8jni.so'
}
}
}

4. Configure mini program SDK dependencies

dependencies {
implementation 'com.google.android.material:material:1.3.0-alpha03'
implementation 'androidx.core:core-ktx:1.6.0'
//gosn
implementation 'com.google.code.gson:gson:2.8.6'
// ok-http
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
// mini app start
kapt 'com.tencent.tcmpp.android:mini_annotation_processor:${version}' // For version information, see Android SDK Updates
implementation 'com.tencent.tcmpp.android:mini_core:${version}' // For version information, see Android SDK Updates
// mini app end
}
Notes:
The {version} in the configuration should be replaced with the version of the dependency.
If you have used annotationProcessor in your project, you need to change all annotationProcessor to kapt.
After the dependency of mini program SDK is configured, you can integrate the mini program SDK.

Preparation before integration

1. Obtain the configuration file

The initialization of the mini program SDK requires configuration file from the mini program console .Follow the steps below.
How to obtain the configuration file:
Log in to the mini program console
Create an app

Fill in the app information



Download the configuration file
Notes:
The default downloaded configuration file is tcsas-android-configurations.json


2. Add the configuration file to the project

After obtaining the configuration file, you need to copy the configuration file to the assets directory of your project.

Notes:
Ensure the app package name matches the packageName in the configuration file. Otherwise, the mini program SDK cannot pass the package name verification when running, which will cause a SDK initialization failure.
If they do not match, you can:
Change the package name in the project to be consistent with the package name in the configuration file. Or
Modify the package name in the console and re-download the configuration file.
The packageName field in the configuration file needs to be consistent with the package name of the project.


3. Add mini program SDK initialization configuration in the source code

Implement the MiniConfigProxy class.
Add the following annotations for the implementation class of MiniConfigProxy:
@ProxyService(proxy = MiniConfigProxy.class)
Example code:
@ProxyService(proxy = MiniConfigProxy.class)
public class MiniConfigProxyImpl extends MiniConfigProxy {
/**
* 'Application' instance of current App
* @return
*/
@Override
public Application getApp() {
return "app Application";
}

/**
* Creates initialization configuration information
* @return
*/
@Override
public MiniInitConfig buildConfig() {
MiniInitConfig.Builder builder = new MiniInitConfig.Builder();
MiniInitConfig config = builder
.configAssetName("tcsas-android-configurations.json") // Configuration file name in assets
.autoRequestPermission(true) // Configure whether the mini program automatically requests necessary system permissions from the user when using APIs that require the permissions
.debug(true) // Log switch, disabled by default
.build();
return config;
}
}
Notes:
The configAssetName of MiniConfig is used to specify the path and name of the configuration file in the project.
At this point, the mini program SDK is integrated. Now you can open and preview the mini program using the API provided by mini program SDK.

Opening a mini program

To open a mini program, use the following code:
Notes:
The appId is the mini program ID, which needs to be obtained from the mini program developer.

TmfMiniSDK.startMiniApp(activity, appId, miniStartOptions);


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon