Consider the following:
minSdkVersion
to 16 because this covers over 99% of devices (1). -D__ANDROID_API__
) must be equal to the minSdkVersion
(3). I've tried to do research to figure out how all of this stuff works -- until now I've mostly been hacking my way through just trying to get dependencies to build in order to port my C++ library to Android -- so forgive me if I'm missing something quite obvious. But it seems to me that the above indicates that apps built with the Android NDK will have to target a minimum of API level 21 starting August 1, 2019. Is this correct?
References:
In the process of my research, I think I found the answer. Please feel free to add a better answer if this one is wrong.
The minimum API level of 21 for 64-bit architectures is due to the fact that Android simply did not support 64-bit before then. By using conditionals in your build scripts and/or makefiles, you can specify the API level as 21 for the 64-bit architectures and still go as low as 16 for the 32-bit ones. In this way you will meet Google's requirements and still provide as much compatibility as you did before. Here's a snippet from one of my own scripts:
case "${ABI}" in
armeabi-v7a | x86)
API_LEVEL=16
;;
arm64-v8a | x86_64)
API_LEVEL=21
;;
*)
echo >&2 "Invalid ABI ${ABI}"
exit 1
;;
esac
Simply compile and include 64bit versions of same 32bit native libs that you have in apk. Leave min SDK version as before.
If app runs on API < 21, it won't see 64bit native libs and it will work with 32bit versions as it did before. On API 21+ the device may use 64bit libs depending on CPU.
Cmake build system will automatically choose correct ndk library to link with from minSdkVersion in build.gradle, so you don't need to care much about setting up build process.
More info: https://developer.android.com/ndk/guides/cmake
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With