Search code examples
androidandroid-sourceandroid-version

Finding out Android's version in AOSP on native code compile time?


I am building AOSP for a device. Is there a way to get the current AOSP version at native code compile time? I am looking for something similar to the LINUX_VERSION_CODE and KERNEL_VERSION(X,Y,Z) directives in Linux. More specifically, I would like to do something that looks like this in one of my own AOSP add-on projects:

#if (ANDROID_VERSION_CODE >= ANDROID_VERSION(4,2,1))
... compile something ...
#else
... compile something else...
#endif

Solution

  • Probably, you can use PLATFORM_VERSION and/or PLATFORM_SDK_VERSION, please see version_defaults.mk