Initialization configurations

更新时间:
复制 MD 格式

The initialization process includes the following steps:

  1. Initialize mPaaS

  2. Configure mini program signature verification

  3. Configure AndroidManifest

  4. Request the UC kernel

Initialize mPaaS

This tutorial uses native Android Archive (AAR) integration. You must initialize mPaaS.

  1. In your project, create a new class named MyApplication. Add the following code to the class:

    public class MyApplication extends Application {
         
        @Override
        public void onCreate() {
            super.onCreate();
            
            MP.init(this,
                MPInitParam.obtain().setCallback(new MPInitParam.MPCallback() {
                    @Override
                    public void onInit() {
                        // Initialize the mini program public resource package.             
                        H5Utils.setProvider(H5AppCenterPresetProvider.class.getName(),new TinyAppCenterPresetProvider());      
                    }
                })
            );
        }
     
    }

    For more information, see Initialize mPaaS.

  2. Open the AndroidManifest.xml file. In the <application> tag, add the following code to specify the Application class.

    android:name=".MyApplication"

Configure mini program signature verification

  1. In your Android project, create a custom_config.json file in the assets/config directory.

  2. Add the following code to the file:

    [
     {
         "value": "NO",
         "key": "h5_shouldverifyapp"
     }
    ]

    Set the value to "NO" to disable mini program signature verification or "YES" to enable it. If you do not specify a value, the default is "YES". You can disable signature verification during development and testing for faster integration. However, you must enable signature verification before you publish the app. For more information about how to configure mini program package signature verification, see Configure mini program packages.

Configure AndroidManifest

Because this tutorial uses native AAR integration, you must add the following configuration to the AndroidManifest.xml file:

<application>
    ···
    <meta-data android:name="nebula.android.meta.enable" android:value="true"/>
  ···
</application>

Request the UC kernel

Note

Due to a policy change, the UC kernel is no longer available for public application. As of December 1, 2022, we no longer accept public applications for UC Keys. You must submit a UC Key application form. Our staff will review your application and notify you of the result.

  1. Click mPaaS > Basic Tools > Generate UC Key Signature Information to open the Query Signature Information window.

  2. In the Query Signature Information window, enter the required configuration information and click Next.

  3. Copy the generated SHA1 information.

    sha1

  4. Add the Key that you obtained in the previous step to your project's AndroidManifest.xml file:

    <meta-data android:name="UCSDKAppKey" android:value="The Key you obtained"/>
    Note

    The UC SDK authorization information is bound to the APK's package name and signature. Therefore, if UCWebView does not work, check that the signature and package name match the information that you provided in your application.

You have now completed the initialization configurations.