Adapt mPaaS to targetSdkVersion 29

更新时间:
复制 MD 格式

Older mPaaS baselines support a maximum targetSdkVersion of 26. Starting with version 10.1.68.21, mPaaS supports targetSdkVersion 29. To upgrade your application to targetSdkVersion 29, use the mPaaS plugin to update the SDK to version 10.1.68.21 or later. Then, adapt your application and perform regression testing on related features as described in this topic.

Adapt to targetSdkVersion 29

Prerequisites

You must first complete the adaptation for targetSdkVersion 28. For more information, see Adapt mPaaS to targetSdkVersion 28.

Modify targetSdkVersion

AAR connection type

In the build.gradle file of the main module of your project, change the `targetSdkVersion` property to 29.

Portal & Bundle connection type

  • In the build.gradle file of the main module of the Portal project, change the `targetSdkVersion` property to 29.

  • The `targetSdkVersion` in the Bundle project can remain unchanged. However, it must not be higher than that of the Portal project.

General configurations

In the project's AndroidManifest.xml file, add the following property under the `application` node:

<application
    android:requestLegacyExternalStorage="true"
    ... >

Use the location feature in the background

If your application needs to use the location feature in the background, add and request the following permissions:

  • Add the permission in the AndroidManifest.xml file:

    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
  • Before you call the location API, request the permission:

    String[] permissions;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
      permissions = new String[]{
          Manifest.permission.ACCESS_FINE_LOCATION,
          Manifest.permission.ACCESS_COARSE_LOCATION,
          Manifest.permission.ACCESS_BACKGROUND_LOCATION
          };
    } else {
      permissions = new String[]{
          Manifest.permission.ACCESS_FINE_LOCATION,
          Manifest.permission.ACCESS_COARSE_LOCATION
          };
    }
    ActivityCompat.requestPermissions(this, permissions, 101);

Use the Mini Program Bluetooth feature

If your application needs to use Bluetooth-related APIs in a Mini Program, add and request the following permissions.

  • Add the permission in the AndroidManifest.xml file:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  • Before you call the Bluetooth API, request the permission:

    String[] permissions = new String[]{
          Manifest.permission.ACCESS_FINE_LOCATION,
          };
    ActivityCompat.requestPermissions(this, permissions, 101);

Regression testing

Ensure that the devices used for full regression testing include devices running Android 10.0 or later.

During regression testing, pay close attention to the features of the following components if they are used in your application:

Component

Validation item

Unified Storage

Check if encrypted database storage works as expected.

Hotpatching

Check if Hotpatching takes effect.

Mobile Analysis

Check if Mobile Analysis stuttering monitoring works as expected.

Mini Program

Location

Check if Location works as expected.