Different Android handsets use different CPUs, which in turn support different instruction sets. The ABI defines, with great precision, how an application's machine code is supposed to interact with the system at runtime.
Each ABI supports one or more instruction sets. Table 1 provides an at-a-glance overview of the instruction sets each ABI supports. ABIs and supported instruction sets. Please refer to the following documentation for more details:. This ABI does not support hardware-assisted floating point computations.
Instead, all floating-point operations use software helper functions from the compiler's libgcc. The instruction extensions that this Android-specific ABI supports are:. Since their presence is not guaranteed, the system should check at runtime whether the extensions are available. If they are not, you must use alternative code paths. For information about how to perform these runtime checks, refer to The cpufeatures Library. The system can perform all internal computations using the FP registers.
Doing so speeds up the computations greatly. Characteristics of this ABI include:. The generated code is an optimization balanced across the top Intel bit CPUs. For more information on compiler flags, particularly related to performance optimization, refer to GCC x86 performance hints. You can still use these extensions, as long as you use runtime feature-probing to enable them, and provide fallbacks for devices that do not support them.
The NDK toolchain assumes byte stack alignment before a function call. The default tools and options enforce this rule. If you are writing assembly code, you must make sure to maintain stack alignment, and ensure that other compilers also obey this rule. These flags target the x instruction set, according to the GCC documentation.
For more information on compiler flags, particularly related to performance optimization, refer to GCC x86 Performance. You can still use these extensions, as long as you use runtime feature probing to enable them, and provide fallbacks for devices that do not support them. It includes the following features:.
It is strongly recommended that you take advantage of split APKs to reduce the size of your APKs while still maintaining maximum device compatibility. At installation time, the package manager unpacks only the most appropriate machine code for the target device. For details, see Automatic extraction of native code at install time.
Since APK files are just zip files, it is trivial to open them and confirm that the shared native libraries are where they belong. If the system does not find the native shared libraries where it expects them, it cannot use them.
In such a case, the app itself has to copy the libraries over, and then perform dlopen. For example, a fat APK may contain:. ARMv7-based Android devices running 4. This issue is fixed from 4. The Android system knows at runtime which ABI s it supports, because build-specific system properties indicate:. This mechanism ensures that the system extracts the best machine code from the package at installation time.
For best performance, you should compile directly for the primary ABI. By contrast, a typical, ARMv7-based device would define the primary ABI as armeabi-v7a and the secondary one as armeabi , since it can run application native binaries generated for each of them.
Using armv8a devices as an example, the device can also run armeabi and armeabi-v7a code. Note, however, that you application will perform much better on bit devices if it targets armv8a rather than relying on the device running the armeabi-v7a version of your application. Many xbased devices can also run armeabi-v7a and armeabi NDK binaries.
For such devices, the primary ABI would be x86 , and the second one, armeabi-v7a. When installing an application, the package manager service scans the APK, and looks for any shared libraries of the form:.
If none is found, and you have defined a secondary ABI, the service scans for shared libraries of the form:. If there is no shared-object file at all, the application builds and installs, but crashes at runtime. You have successfully signed up for the latest Android developer news and tips. You requested a page in , but your language preference for this site is. Would you like to change your language preference and browse this site in? If you want to change your language preference later, use the language menu at the bottom of each page.