Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting OS version with NDK in C

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?

like image 697
Stephan Avatar asked Oct 14 '13 08:10

Stephan


People also ask

How do I know what version of NDK I have?

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.

Which version of NDK should I use?

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.

How do you use NDK?

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.

What is NDK Sysroot?

$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/….


1 Answers

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.

like image 82
alijandro Avatar answered Oct 22 '22 01:10

alijandro