Solve the problem caused by targetSdkVersion rising to 30

Recently, the Huawei market requires that the targetSdkVersion of the app be raised to 30+ before January 2024, so after the modification, various functions were checked. The main problem found so far is a problem with the networking function.

1. Access http link prompt ERR_CLEARTEXT_NOT_PERMITTED

Temporary solution:

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

Ultimate solution:

Own server http -> https

Third-party interface server: require the other party to provide an https interface

2. QQ SDK cannot transfer to QQ login interface

It prompts that QQ is not the latest version (actually it is already the latest version); I thought that my QQ SDK version was too low (2018), and I wanted to replace it with the latest version, but I found a simpler solution online:

"Add permission query for Android API 31 system version 12, otherwise the Android 12 system will not be able to jump to the authorization page, causing the user to click the login button and not be able to query the Tencent QQ APP installed on the phone."

In fact, my Xiaomi Youth 10 is the Android11 ​​version, and it cannot be transferred to the QQ login interface, which is not the "31/12" mentioned above; it can also be solved with the following method (that is, adding mobileqq's queries in the manifest)

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:installLocation="auto"
    package="your.package.name"
    android:versionCode="66"
    android:versionName="6.6.6" >

    <queries>
        <package android:name="com.tencent.mobileqq" />
    </queries>

    <!-- ... -->

</manifest>

However, for my app, the above targetSdkVersion was modified and <queries> was added, resulting in an error during compilation:

at com.android.build.gradle.internal.tasks.manifest.ManifestHelperKt.mergeManifestsForApplication

My project is composed of multiple sub-projects, so I checked the .gradle of each sub-project and found that I only changed the targetSdkVersion in the .gradle of the entry project to 30. After modifying the .gradle of each sub-project, the above error was still prompted. So execute in the Terminal of Android Studio:

gradlew processDebugManifest --stacktrace

Get more detailed tips including:

Missing 'package' key attribute on element package at AndroidManifest.xml:10

I searched online for a solution to this problem. I need to upgrade the gradle plug-in version of the main project (originally 3.5.2).

dependencies {
        classpath 'com.android.tools.build:gradle:3.5.4'
    }

These problems have been discovered for the time being, and all third-party interfaces such as Weibo SDK and packaged installation still need to be tested.

Installation test (re-sign with local jarsigner command after 360 reinforcement)

1. ✔Go to Honor Youth 10: EMUI 10.0.0/Android 10

2. ✔ To MIX2: MIUI 12.0.1/Android 9 

3. × When it comes to Xiaomi Youth 10: MIUI12.1.7/Android 11, it prompts that there is a problem when parsing the software package. (33) Details: packageinfo is null

The same is true after testing Tencent reinforcement and Bangbang reinforcement.

Initially I thought it was a problem with the Android Studio version/Gradle version, so I upgraded to the latest Giraffe and gradle to 7.5.

classpath 'com.android.tools.build:gradle:3.5.4' upgraded to 7.4.2, still the same.

(Upgrading from Android Studio V3.5.2 to Giraffe, and gradle from 5.4.1 to 7.5, and tools.build:gradle from 3.5.4 to 7.4.2 are a bunch of mistakes. I will summarize them later when I have time)

If you use an unhardened signature package or install the hardened package directly, that is, without signing with the local jarsigner command, there will be no such problem.

So it is determined that there is a problem with the local jarsigner version after the targetVersion is changed to 30 (that is, it can be installed on some devices, but not on some devices).

So I downloaded the 360 ​​hardened client, signed the hardened package with the signature V3 (=V1+V2) in the toolkit, and found that problem 3 was solved.

Guess you like

Origin blog.csdn.net/piggy514/article/details/133547407