官术网_书友最值得收藏!

Supporting multiple CPU architectures

Android NDK supports different CPU architectures such as ARMv5TE and ARMv7-based devices, x86, and MIPS (big-endian architecture). We can create fat binaries that can run on any of the supported platforms.

Getting ready

Find out the architecture of your Android-based device. You can do it using the adb command as follows:

>adb shell cat /proc/cpuinfo

How to do it...

The following are the two approaches to pick an appropriate set of CPU architectures:

  1. By default, the NDK will generate the code for ARMv5TE-based CPUs. Use the parameter APP_ABI in Application.mk to select a different architecture, for example (use only one line from the following list):
    APP_ABI := armeabi-v7a
    APP_ABI := x86
    APP_ABI := mips
  2. We can specify multiple architectures to create a fat binary that will run on any of them through the following command:
    APP_ABI := armeabi armeabi-v7a x86 mips

There's more...

The main pitfall of the fat binaries is the resulting .apk size, as separate native code versions are compiled for each of the specified architectures. If your application heavily uses third-party libraries, the package size can become an issue. Plan your deliverables wisely.

主站蜘蛛池模板: 华亭县| 靖江市| 青海省| 德江县| 康乐县| 新兴县| 嘉兴市| 肃宁县| 拜泉县| 永德县| 新昌县| 青海省| 石楼县| 平谷区| 阜康市| 双桥区| 深泽县| 泰顺县| 威海市| 福鼎市| 阆中市| 宝鸡市| 大竹县| 大方县| 龙游县| 敦煌市| 慈利县| 安义县| 平谷区| 当阳市| 平武县| 桂东县| 松桃| 东港市| 出国| 剑河县| 永善县| 项城市| 肃宁县| 项城市| 泾源县|