Integrate with Android

更新时间:
复制 MD 格式

If your app requires internationalization, follow these steps:

  • Adapt for multiple languages (English/French/Russian)

  • Check the integrated components

    Review your integrated components. Some components that depend on the Amap SDK or the hot patch component may not be approved by Google Play. You may need to replace or remove these SDKs or components. Additionally, some third-party SDKs may send data to the Chinese mainland. You can remove these components as needed.

  • Use Blue Shield

    Replace Security Guard with Blue Shield and configure multiple Blue Shield images if necessary.

Language adaptation

English

The mPaaS SDK has fully supported English since the mPaaS Android 10.2.3.68 baseline. We have also released the international 10.2.3.global baseline. You can upgrade to baseline 10.2.3.68 or a later version, or use the 10.2.3.global baseline directly. Then, use the official Android Locale API to either manually set the language to English or let the app follow the device's system language.

French/Russian

To add support for French or Russian, obtain the required language packs by joining our DingTalk group (ID: 145930007362) or by submitting a ticket to mPaaS technical support. Place the resource files in the res/values-fr/strings.xml and res/values-ru/strings.xml directories of your project. Then, use the official Android Locale API to either manually set the language or let the app follow the device's system language.

Check the integrated components

Amap location and map

The following components depend on the Amap location or map SDK, some versions of which may not be approved by Google Play. You must manually remove the related dependencies based on your integration method:

  • Mini Program

  • Mriver Mini Program

  • Native Mini Program (private cloud)

  • Mobile Content Delivery Platform

Because these components depend on the AutoNavi location or map SDK, you need to manually remove the related dependencies based on your integration method:

Remove Amap SDK dependency

  • Native AAR integration

In the build.gradle file of your main module, add the following configuration:

configurations.all {
    exclude group:'com.mpaas.group.amap', module: 'amap-build'
    exclude group:'com.alipay.android.phone.thirdparty', module: 'amap3dmap-build'
    exclude group:'com.alipay.android.phone.mobilecommon', module: 'lbs-build'
}
  • Component-based (Portal & Bundle) integration

In the build.gradle file of your main module, add the following configuration:

mpaascomponents {
    excludeDependencies = [
        "com.mpaas.group.amap:amap-build",
        "com.alipay.android.phone.thirdparty:amap3dmap-build",
        "com.alipay.android.phone.mobilecommon:lbs-build",
    ]
}

Use the location component

If you have integrated the location component, you must remove amap-build and amap3dmap-build as described previously, but do not remove lbs-build. You must also import a version of the Amap SDK from the official Amap website that is approved by Google Play. mPaaS uses the following Amap SDK versions. Use this list to select a compatible, Google Play-approved version.

'com.alipay.android.phone.mobilecommon:AMap-2DMap:5.2.1_20190114@jar'
'com.alipay.android.phone.mobilecommon:AMapSearch:6.1.0_20180330@jar'
'com.alipay.thirdparty.amap:amap-location:4.7.2.20190927@jar'

Hot patch

Google Play policy prohibits apps from dynamically downloading executable code. Integrating the hot patch component may cause your app to be rejected during review. We recommend that you do not integrate the hot patch component.

Third-party SDK data transmission

Third-party SDKs included in the mPaaS SDK may send requests to servers located in the Chinese mainland. If you do not want your app to send data to the Chinese mainland, ensure you have not integrated the following components:

  • UC kernel

  • Sharing

  • Push - Xiaomi

  • Location

  • Youku player

Also, see the Remove Amap SDK dependency section above.

Use Blue Shield

Replace Security Guard with Blue Shield

The Security Guard component is no longer maintained, so its compatibility with targetSdkVersion 34 or higher is not guaranteed. To replace it, see mPaaS 10.2.3 support for switching between Security Guard and Blue Shield.

Configure multiple Blue Shield images

When an mPaaS component sends a request to the gateway, it uses Blue Shield for signing. The signing information is stored in a Blue Shield image. This image is bound to the application's signature. If the application's signature changes, you must generate a new Blue Shield image; otherwise, signature verification for requests will fail.

If your app needs to use multiple signatures in different scenarios, such as:

  • Enabling the Google Play re-signing mechanism

  • Using the key rotation feature of v3 signatures

Follow these steps:

  1. Build the APK with signature 1. See the Generate Blue Shield Image document. The default image path is assets/abs_1222.jpg. Rename this image, for example, to abs_1222_jks1.jpg.

  2. Build the APK with signature 2. See the Generate Blue Shield Image document and rename the generated image, for example, to abs_1222_jks2.jpg.

  3. (Optional) If you use the Google Play re-signing mechanism, you can download the re-signed APK directly from Google Play and use it to generate the corresponding Blue Shield image.

  4. Your project now contains two Blue Shield images under the assets directory:

    • assets/abs_1222_jks1.jpg

    • assets/abs_1222_jks2.jpg

  5. Call the following API at app startup to specify the Blue Shield image to use:

    MPBS.setBSAuthCodeDynamically(String bsAuthCode);
    • This API is supported in baseline version 10.2.3.67 and later.

    • The bsAuthCode parameter is the name of the Blue Shield image file without the extension. For example, if the image file is abs_1222_jks1.jpg, pass abs_1222_jks1. If you do not call this method, the default image name abs_1222 is used.

    • This method must be called before mPaaS is initialized. We recommend calling it in the attachBaseContext method. Once mPaaS initialization is complete, any subsequent calls to this API will have no effect.

  6. Your application logic determines which image to use. The following code provides examples.

    // v3 signatures are supported starting from Android 9
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        MPBS.setBSAuthCodeDynamically("abs_1222_jks2");
    } else {
        MPBS.setBSAuthCodeDynamically("abs_1222_jks1");
    }
    
    // Apps re-signed by Google Play are delivered to Android 13+ devices
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
        MPBS.setBSAuthCodeDynamically("abs_1222_jks2");
    } else {
        MPBS.setBSAuthCodeDynamically("abs_1222_jks1");
    }