I'm trying to better understand how the selection of the api level works when using ndk-build.
I know I can explicitly set APP_PLATFORM
in Application.mk, and that otherwise ndk-build will target the api indicated in the manifest with android:minSdkVersion
, but what if my application's manifest has both android:minSdkVersion
and android:targetSdkVersion
, and this is higher than minSdkVersion?
Will ndk-build target the targetSdkVersion? And how can I check that?
In case it targets the higher api level, I guess that I will be able to build using native apis only available for that level, but if I run the application on a device with lower api level it should miserably fail, so in that case I should implement some sort of api level checking, is that correct?
Android:minSdkVersion
The minimum version of the android platform on which the application will run.
Android:targetSdkversion
Specifies the API level on which the applicaion is designed to run.
Android:maxSdkVersion
The maximum version of the Android platform on which the application is designed to run.
Put this code into your
Android.mk
just after you define TARGET_PLATFORM and LOCAL_CFLAGSNow you can check this defines in your C/C++ code:
Use
__ANDROID_API__
defined in$NDK/platforms/android-<level>/<abi>/usr/include/android/api-level.h