Obtaining Configuration Files
Developers obtain the configuration files corresponding to the App from TCMPP. This configuration file, a JSON file, contains all information related to the App's usage of TCMPP and is incorporated into the root directory of the project's assets. For operations pertaining to obtaining configuration files, see Obtaining Container SDK Tokens. Caution:
The application package name must remain consistent with the "packageName" in the configuration file. Otherwise, it will fail the runtime validation.
In the case of inconsistency, do no directly change the package name in the configuration file. Instead, use the following two methods to change the name:
Change the application package name within the project to match the package name in the configuration file.
Change the application package name in the console to align with the application package name within the project, and subsequently re-download the configuration file.
Configuration Information Settings
Implement the MiniConfigProxy Class
Add the following annotations:
@ProxyService(proxy = MiniConfigProxy.class)
Reference Code:
@ProxyService(proxy = MiniConfigProxy.class)
public class MiniConfigProxyImpl extends MiniConfigProxy {
@Override
public Application getApp() {
return "app Application";
}
@Override
public MiniInitConfig buildConfig() {
MiniInitConfig.Builder builder = new MiniInitConfig.Builder();
MiniInitConfig config = builder
.configAssetName("tcmpp-android-configurations.json")
.imei("IMEI")
.debug(true)
.build();
}
}
Upon inheriting and implementing the MiniConfigProxy class, the mini-program can be launched through the startup interface, and the SDK will automatically initialize.
From version 1.5.1.1 of mini_core onwards, you can filter logs through MINI_SHARK to ascertain whether initialization is successful. If successful, the output will be "shark init ok!"
If initialization fails, the output will be "shark init failed!", along with the specific reason for the failure.
If the initialization fails, you can troubleshoot by considering the following common reasons.
Troubleshooting Project Compilation Failure
Reason 1: The following error occurred.
Inspect the project for the following configuration. If present, remove it.
kapt.include.compile.classpath=false
Troubleshooting Mini Program Launch Failure
Reason 1: Incorrect configuration file path. The 'configAssetName' is set with a complete file path in the "assets" directory. If the configuration file is in a subdirectory, the directory path needs to be appended. For example: server/tcmpp-android-configurations.json.
Reason 2: The mini program configuration file is changed, preventing the mini program from functioning properly.
Reason 3: The packageName in the configuration file must match the application's applicationId. Otherwise, the App will fail to run, because the initialization process verifies the packageName in the configuration file. The package name verification can be bypassed through the following setting.
MiniInitConfig config = builder
.verifyPkg(false)
.build();
Reason 4: Check whether the initialization annotation @ProxyService has generated the following class: ExtProxyServiceScope.
Privacy Compliance Descriptions
The SDK initialization is called when the user calls a method from the TmfMiniSDK class. Therefore, after the user has agreed to the privacy compliance authorization, they can proceed to calling the methods provided in the TmfMiniSDK class.
Other Initialization Actions (optional setting)
Set the region or account for convenience when conducting gray-scale push operations.
public static void setUserId(String userId)
public static void setLocation(String country, String province, String city)
X5 Initialization Listening (optional setting)
Upon the need of listening to whether X5 initialization is successful, the initialization callback can be obtained through the following method.
@ProxyService(proxy = IX5EventProxy.class)
public class X5EventProxyImpl implements IX5EventProxy {
@Override
public void init(boolean isX5) {
}
}
Was this page helpful?