The Android platform configures the CPU type for the so library developed and generated using the C/C++ language in order to improve the operating efficiency. It is necessary to compile and generate the corresponding instruction so library for each CPU type platform separately. The code developed in the Java language runs in the virtual machine, and the virtual machine adapts the CPU type, which does not involve this problem.

Functions (modules) using the so library in HBuilder/HBuilderX

  • Audio (recording): supports mp3 format
  • Geolocation: Baidu
  • LivePush (live streaming)
  • Maps: Gaode, Baidu
  • OAuth (login authentication): Sina Weibo
  • Push (message push): individual push, UniPush
  • Share: Sina Weibo
  • Speech (voice input): Baidu, Note: iFLYTEK does not support 64-bit
  • Weex (native rendering): uni-app (custom component mode, nvue page), Note: HBuilderX2.1.5 and above versions support
  • Android X5 Webview (Tencent TBS): Tencent X5 kernel, Note: x86 is not supported

HBuilderX2.7.0+ 调整 云端打包默认不再包含 x86 CPU类型库,减少apk包体积详情 HBuilderX2.1.5+ began to support the new 64-bit CPU type for Android platform, and cloud package supports configuration of CPU types supported by App Meet the requirement that apps uploaded on Google Play from August 1, 2019 must support 64-bit CPU.

# CPU type

HBulderX has been adapted to support the following mainstream CPU types:

  • armeabi-v7a 7th generation and above ARM processors (ARM32-bit), most mobile phones on the market use this CPU type.
  • arm64-v8a The 8th generation, 64-bit ARM processor (ARM64-bit), the newly released devices in the last two years use this CPU type, which is compatible with the so library of armeabi-v7a.
  • x86 A small number of tablets use x86, when intel x86 is selected in the AS simulator, the x86 processor is used, and other commonly used third-party simulators usually use x86

不支持64位x86指令cpu,即不支持x86_64

Note: If x86 is not checked, it may not work properly on the emulator. The following are common emulators that need to include x86

  • Thunderbolt Simulator: 3.x must include x86 or it will not work properly; 4.x does not need to include x86.
  • NoxPlayer: Must include x86 or it won't work
  • MuMu Simulator: No need to include x86
  • MEmu Emulator: No need to include x86
  • BlueStacks (BlueStacks Simulator): No need to include x86
  • Tencent Simulator (Mobile Game Assistant): Must include x86 or it won't work
  • Other emulators: Not tested and verified, it is recommended to include x86 to ensure normal operation in the simulator

# 配置支持的CPU类型

可视化界面配置

源码视图配置 Open the manifest.json file of the project, switch to the "source view", and configure according to the project type

  • uni-app项目 在 "app-plus"->"distribute"->"android" 节点的 abiFilters 属性配置支持的CPU类型,示例如下:
  "app-plus": {
    "distribute": {
      "android": {
        "abiFilters": [
          "armeabi-v7a",
          "arm64-v8a"
        ]
        //...
      },
      //...
    },
    //...
  },
  //..

# Offline packaging configuration

Use Android studio to open the Android native project and open the build.gradle file of the corresponding project. 在Android -> defaultConfig下添加支持的CPU类型,如下示例:

defaultConfig{
	ndk {
    abiFilters 'arm64-v8a','armeabi-v7a'
  }
}

Note: Offline packaging only supports three types: arm64-v8a, armeabi-v7a, and x86. It is recommended to choose the type of CPU packaged according to your needs

# 默认值

  • HBuilderX3.92及以下版本,默认值为armeabi-v7a
  • HBuilderX3.93及以上版本,为了充分发挥CPU性能,默认值调整为arm64-v8a。解决在部分华为鸿蒙新设备(如Mate60、Mate X5等)应用启动慢的问题。

# CPU type selection suggestion

ARM64-bit (arm64-v8a) CPU is compatible with ARM32 instructions, that is to say, only the so library of type armeabi-v7a can also run on 64-bit mobile phones, but it does not fully utilize the performance of the CPU. 选择支持的CPU类型时请参考以下建议:

  • 如果不在意apk大小,三种CPU类型都勾选
  • 如果要尽量发挥新设备性能,选择arm64-v8a
  • 如果在意apk大小,选择armeabi-v7a(几乎在所有ARM指令的所有设备上都可正常运行)
  • 如果想兼容性能和apk大小,建议选择armeabi-v7a、arm64-v8a
  • 如果要兼容一些平板和模拟器,选择armeabi-v7a、x86 不是所有模拟都仅支持x86指令,如雷电(4.x)、MuMu等模拟器也是支持ARM指令。

# 查看apk支持的CPU类型

# 常见问题

# 在部分华为鸿蒙设备上启动应用慢的问题

部分华为新设备(Mate60、Mate X5等)使用的芯片运行32位应用时只能跑在小核上,相当于限制的CPU的性能,如果应用只包含armeabi-v7a会导致应用启动速度非常慢。需要勾选arm64-v8a来解决此问题。 为了适配更多的新设备,建议开发者尽量勾选arm64-v8a。

# The CPU type is configured with x86, and the cloud package does not include x86

如果勾选了不支持x86的内置模块或uni原生插件,云端打包后不会包含x86

  • 不支持x86的内置模块
    • Android X5 Webview(腾讯TBS)
  • uni原生插件
    • For cloud plugins, you can check the compatible CPU types in the "Platform Compatibility" of the plugin details page
    • Mainland plug-ins can view the abis attribute configuration in package.json

# 上架Google Play市场对CPU类型的要求

提交Google Play时要求支持64位,建议选择"armeabi-v7a"和"arm64-v8a"两个即可,也可以只选择"arm64-v8a"。

Note: Do not check "x86"

# CPU type error installation prompt

If the CPU type selected by the package is not compatible with the device, it will not be installed normally. Installation through adb command usually prompts the following error:

Performing Streamed Install
adb: failed to install android_debug.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]

# HBuilderx2.7.0+ 云端打包默认CPU类型不再包含x86

At present, common mobile phones on the market use ARM processors, and few devices use x86 processors. Therefore, starting from HBuilderX2.7.0, cloud packaging is adjusted to no longer contain x86 CPU types by default, reducing the size of the apk package:

  • uni-app project The basic function apk is reduced by 5M+. The more third-party SDKs and uni native plug-ins are used, the larger the package size will be reduced. The specific value depends on the size of the x86 type so library it contains.
  • 5+App, Wap2App project The basic function apk is reduced by 100K+. If there is a so library in the third-party SDK used, the reduced size will be larger. The specific value depends on the size of the x86 type so library it contains.

Note: Most emulators (like Nox) must include x86, otherwise the app may start with a white screen, please configure it according to the tutorial above