According to NDK's official download page: https://developer.android.com/ndk/downloads there are two target versions:
And I was wondering ( as a newbie in the NDK stuff ), does this mean I should use the x64 NDK when compiling an application for devices equipped with x64 processors?
And if I need only one ".apk" file, how to make it contain both x86 & x64 builds? ( if possible of course )
Update: The question is a bit outdated now. Starting from version 10c
NDK is distributed in a single package for all target platforms again. The answer has been updated to reflect this fact.
First of all, you should distinguish between the architecture of the device where your application will run (which can be ARM (several kinds) 32 or 64 bit, MIPS 32 or 64 bit, and Intel x86 / x64) and the architecture/OS of your build machine (which can be Windows, Linux or Mac all running on Intel x86 / x64 processors).
So suppose you have Windows 64 bit. Then (as right now the latest version is 10d
) you should download android-ndk-r10d-windows-x86_64.exe
. It will allow you to build for all target platforms supported by NDK (32 and 64 bit).
If you build for 32-bit target device, the application will run on 64-bit device as well, because all listed 64-bit architectures are backward compatible with their 32-bit counterparts.
But if you want to use 64-bit specific features of target architecture, you should use 64-bit toolchains. If you build only for 64 bits, the application won't run on 32-bit architecture.
If you have to support several targets (like ARM and Intel x86), in your Application.mk
you can specify targets which you want your native code to be built for (google for APP_ABI
), so you'll build several versions of native library and the system will load the appropriate one in runtime. Also this way you can provide separate binaries for 32 and 64 bit versions of same architecture family, so you may fine-tune them.
You may further read the docs inside NDK package, they are quite exhaustive.