05/15/2024 15:19:45

Solution

I. Background

Google Play Store requires Apps that release after August 2022 and are updated after November must upgrade their Target API to Target API 31.

Reference:

  1. https://developer.android.com/google/play/requirements/target-sdk

    Starting in August 2022, new apps must target API level 31 (Android 12) or above and adjust for behavioral changes. Wear OS apps must target API level 28 or higher.Starting in November 2022, app updates must target API level 31 or above and adjust for behavioral changes in Android 12.

  2. https://support.google.com/googleplay/android-developer/answer/11926878?hl=en

II. How to upgrade to Target API 31

In short, just change the value of the compiled targetSdkVersion to 31

2.1 Android Studio and Gradle compilation projects

Generally, in the build.gradle file in the App directory, just modify the value of android ->defaultConfig -> targetSdkVersion to 31. For example:

Image Description

2.2 Unity projects

In the Unity menu's File -> Build Settings ... pop-up window, select Android in Platform, and in Player Settings ...

Image Description

open the Inspector panel and find Other Settings -> Target API Level and then make settings in it

Image Description

2.3 UnrealEngine Project

Open the pop-up window in the UnrealEngine menu's File -> Package Project -> Packaging Settings...,

Image Description

and find the Platforms -> Android configuration option and then modify the corresponding configuration

Image Description

III. Configuration and handling

3.1 Change of security and privacy settings - Location information

   In Android 12 (API level 31) or higher versions, the user can request the application to only retrieve the approximate location information (that is, only give the application ACCESS_COARSE_LOCATION permission); even if the application requests ACCESS_FINE_LOCATION runtime permission, it is also so

The official documentation about requesting the location permission: https://developer.android.com/training/location/permissions#approximate-request

Warning: It is required to include ACCESS_COARSE_LOCATION permission and ACCESS_FINE_LOCATION permission in a single runtime request at the same time

1) Permission Declaration

   Declare the ACCESS_COARSE_LOCATION permission and the ACCESS_FINE_LOCATION permission in the AndroidManifest.xml file

//Permission declaration
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

2) Handle the low positioning accuracy situation

   When the target API of the application is 31, for an Android12 user, if the user is only allowed to obtain the approximate location, the positioning accuracy may be too low due to the influence of the GPS signal strength, and even positioning timeout and failure may occur. To improve the success rate and accuracy of positioning, the app can properly guide the user to open the accurate location information

3) Notes on privacy compliance

   In order to improve the success rate of positioning, two system APIs are used to obtain the information of nearby base stations to assist positioning. The specific method is to give priority to the use of a higher version of getAllCellInfo. If it fails, getCellLocation is used. It is necessary to explain the relevant compliance rules here: if getAllCellInfo fails, the invocation of the interface for obtaining the information of base stations will be increased by one times.

3.2 Change of component export

   When the application uses Android 12 or higher versions as the target platform and contains activities, services or broadcast receivers that use the intent filter, it is required to explicitly declare the android:exported attribute for the above components. MSDK has processed all the internal components accordingly, so the application does not need to configure them.

   When the application uses Android 12 (API level 31) or higher versions as the target platform, WebView will include changes to third-party cookie processing methods. The application needs to use appropriate values to explicitly set the SameSite attribute in Cookie when necessary. For detailed change instructions, see the link below.

Official documentation about WebView changes: https://developer.android.com/about/versions/12/behavior-changes-12#samesite

3.4 Description of package visibility

   If the application uses Android 11 or higher versions as the target platform and there is an application scene that invokes other applications to log in and share messages, the application needs to add a <queries> element in its own AndroidManifest.xml and declare the corresponding application package name

<manifest package="com.example.game">
    <queries>
      <!--  Specify the package name of QQ. This can invoke QQ-related applications to perform corresponding operations -->
        <package android:name="com.tencent.mobileqq" />
        <package android:name="com.tencent.tim" />
        <package android:name="com.tencent.minihd.qq" />
        <package android:name="com.tencent.qqlite" />


        <!--  Specify the package name of WeChat. This can invoke WeChat to perform corresponding operations -->
         <package android:name="com.tencent.mm" />

         <!--  Specify the package name of twitter. This can invoke twitter to perform corresponding operations -->
         <package android:name="com.twitter.android" />

         <!-- Specify the package name of facebook. This can invoke facebook-related applications to perform corresponding operations -->
         <package android:name="com.facebook.katana" />
          <package android:name="com.facebook.lite" />
          <package android:name="com.facebook.orca" />
          ...

    </queries>
    ...
</manifest>

Package names used in access to different MSDK plug-ins: https://docs.msdk.qq.com/v5/zh-CN/FAQS/a69f6882042ddb9e04b8ba73f37404dc/6c6fa88eaf6f031730bc19ff125ce4cd.html

Official documentation about package visibility: https://developer.android.com/training/package-visibility/declaring

IV. Component SDK upgrading

4.1 Garena

1) Version requirements

Garena's SDK version needs to be >=4.0.21.

2) Upgrading method

Replace the original plug-in with the new version.

4.2 facebook

1) Version requirements

Facebook must be upgraded to version 12.2.0 or above.

2) Upgrading method

Replace the original plug-in with the new version.

V. Warning about upgrading

5.1 Gradle version requirements

   After target API is upgraded to 30 and above, when the <queries> tag is used, the Gradle plug-in version must be at least 3.3.3, and the Gradle version must be at least 4.10.1. If these do not meet the requirements, an xml file merge error will be reported during the compiling process:

> Task :app:processDemoDebugManifest FAILED
> Error: Missing 'package' key attribute on element package at AndroidManifest.xml:...

Solution:
Upgrade the Android Gradle plug-in version to 3.3.3 or above and the Gradle version to 4.10.1 or above.



Copyright © 2024 MSDK.
All rights reserved.

results matching ""

    No results matching ""