1, the background,

On August 1, 2019, apps published on Google Play must support 64-bit architecture

Five major App stores, including Xiaomi App Store, OPPO App Store, Vivo App Store, Tencent App Bao and Baidu Mobile Assistant, announced that they will jointly promote the 64-bit architecture upgrade of The Domestic Android ecosystem in order to better improve the App performance experience and reduce power consumption.

Specific timetable:

By the end of December 2021, existing and newly released apps and games will need to upload the APK package containing the 64-bit package. This means that all apps uploaded should contain a 64-bit version of the code, not only a 32-bit version of the app uploaded.

By the end of August 2022, only 64-bit versions of APK packages will be accepted for hardware systems that support 64-bit. If you have hardware that supports a 64-bit system, you will only run the 64-bit version of your application.

By the end of 2023, hardware will only support 64-bit APK, and 32-bit applications will not run on terminals.

It is inevitable that applications will be released to support 64-bit systems,

2, research

The status quo

The current mobile CPU architecture is Armeabi, ArmeabI-V7A, ARM64-V8A, x86, x86_64,

However, at present, most mobile phones are based on ARM architecture, while x86 phones are basically not. They are basically tablets, which can be ignored

Armeabi was the mobile CPU architecture of a decade ago, and it’s basically gone

Armeabi-v7a’s CPU architecture is 32-bit,

The CPU architecture of arm64-V8A is 64-bit

Therefore, the armeABI-V7A and ARM64-V8A that need to be considered at present are ok.

In the past, developers used to specify armeabi-V7A so packages only for the sake of package size, so that the package size can be much smaller, especially for applications with many so libraries

ndk {
    // Select the.so library for the CPU type to be added. Separate multiple ABI's with a comma.
    abiFilters 'armeabi-v7a'
    // The specified values are 'armeabi-v7a', 'arm64-v8A ', 'armeabi', 'x86', 'x86_64',
}
Copy the code

The NDK can be configured in the gradle of the project. The 64-bit mobile phone will adapt to the 32-bit application, which is perfectly compatible with 99.9% of mobile phones on the market, and the package size will be much smaller

However, the performance of the 64-bit processor is not perfect, so what are the benefits of using 64-bit?

Due to the increasing functions of some software, the volume of the installation package and the running memory required to consume are becoming larger and larger, and the limitations of 32-bit applications are becoming more and more prominent. 64-bit systems, which can use more than 4GB of operating memory in a single thread, can take advantage of the advantages of mobile hardware when processing large software or high-pixel images and videos. For example, some large games, live network video, high quality video and so on. And 64-bit systems offer at least a 20% increase in efficiency over 32-bit systems.

Entering the 64-bit SO package will inevitably lead to a large increase in the package size, resulting in poor download experience for users. Currently, Google Paly supports uploading two APKs of 32-bit and 64-bit, so that users can dynamically download the APK according to the CPU architecture of the phone

It is currently not supported in the domestic market, but this is the trend, and this function will be inevitable in the future. When we are developing, we still need to support the two architectures’ Armeabi-V7A ‘and’ ARM64-V8A ‘for the time being, and the package size will also be greatly increased

3. Treatment scheme

Dev.mi.com/distribute/… Xiaomi App Store supports 64-bit architecture adaptation guidelines

Dev.vivo.com.cn/documentCen… Vivo App Store 64-bit architecture adaptation guide \

Open.oppomobile.com/wiki/doc#id… Oppo App Store 64-bit architecture adaptation guide \

The easiest way to determine whether an application contains a 64-bit library is to examine the structure of the APK file. At build time, APK is packaged with all the native libraries required by the application. Native libraries are stored in different folders depending on the ABI. Your application does not have to support all 64-bit architectures, but it must include a corresponding 64-bit architecture for each of the native 32-bit architectures supported.

For the ARM architecture, the 32-bit libraries are in Armeabi-V7a. The corresponding 64-bit library is in ARM64-V8A.

For the x86 architecture, the 32-bit libraries are in x86 and the 64-bit libraries are in x86_64.

So how do you view the architecture of APK

Click on the typed APK package and it will appear in the current APK architecture

In build.gradle change NDK dependencies to ‘armeabi-v7a’, ‘arm64-v8a’

ndk {
            // Select the.so library for the CPU type to be added. Separate multiple ABI's with a comma.
            abiFilters 'armeabi-v7a'.'arm64-v8a'
            // The specified values are 'armeabi-v7a', 'arm64-v8A ', 'armeabi', 'x86', 'x86_64',
        }
Copy the code

The result of the bag played

The package needs to be tested on a 64-bit test machine. How to check the CPU architecture of your Android phone?

To view the CPU architecture information of an Android device, run the following command:

1, the adb shell

2, the cat/proc/cpuinfo

CPU Architecture: 7 indicates ARM-V7, and 8 indicates ARM-V8

AArch64 is an execution state of the ARMv8 architecture.