Relation between the NDK version and the Android v

2019-07-04 05:15发布

问题:

Is there any relation (constraint/compatibility restriction) between the version of the NDK used to compile the native code and the Android version running on the device where the APK is installed?
For example, I compile the native code with Android NDK r7, I get the libraries and generate APK1; then I compile with NDK r10d, obtain the libraries and generate APK2.

Is it any risk that I might get different behavior between APK1 and APK2 running on the same device?

回答1:

Bugs are found and fixed in NDK. So the later versions are generally better. But bugs may be introduced in later versions, so keep tracking the forums (e.g. SO and groups/android-ndk), track issues, and be ready to upgrade at any time.

The compilers included in NDK improve with the time, including optimizations. So, later versions may produce faster executables.

Also, while the 64-bit systems can run 32-bit executables, later NDK versions can produce native 64 bit binaries that will be much faster on such devices.

Don't confuse the NDK release with the platform! Even r.10e has support for all older platforms, but if you build your app for android-21, it won't load on devices with Froyo. On the other hand, forward comparability is usually OK, and mostly programs built for android-9 will run on all newest devices, but there may be glitches, and such binaries may underutilize the new platform, and be less efficient than the ones compiled for the highest platform.