I'm writing a C program which I want to execute on my Desktop running Linux and also on an Android device.
I have to make some Desktop specific things and some Android specific things.
My question is, is there a way to get the OS version in C so I can handle if the program is executed on the Desktop or on the Android device?
With a project open, click Tools > SDK Manager. Click the SDK Tools tab. Select the Show Package Details checkbox. Select the NDK (Side by side) checkbox and the checkboxes below it that correspond to the NDK versions you want to install.
You should always be using the latest NDK for the best behavior (possibly N-1 if there's a bug in the latest stable, but that won't be the average case). It does sound like your APP_PLATFORM is set to a newer platform than the device you're trying to run on. APP_PLATFORM is a minimum supported version.
You can automatically install the required NDK and CMake using the Android Gradle Plugin 4.2. 0+ when the project is first created, provided their licenses are accepted beforehand. If you have read and agree to the terms of the license, you can use the following command to pre-accept the license in the script.
$NDK/sysroot is the unified headers and is what you should be using when compiling. When linking, you should still be using $NDK/platforms/android-$API/arch-$ARCH . We do have a doc explaining how to use unified headers in a custom build system: android.googlesource.com/platform/ndk/+/master/docs/….
NDK provide direct api to get app target sdk version or api level
android_get_device_api_level
android_get_application_target_sdk_version
See the ndk official document.
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