Android – how do I know which API level I’m building with NDK build?

I'm trying to better understand how to choose API levels when using NDK build

I know I can explicitly set the app in application.mk_ Platform, otherwise NDK build will use Android: minsdkversion to locate the API indicated in the listing, but if the listing of my application contains both Android: minsdkversion and Android: targetsdkversion, then this is higher than minsdkversion?

Will NDK build locate targetsdkversion? How can I check it?

If it is for a higher API level, I think I will be able to build with native APIs that only apply to that level, but if I run the application on a device with a lower API level, it should fail, so in this case, I should implement some API level check. Is that correct?

resolvent:

When defining target_ Platform and local_ After cflags, put this code into android.mk

ifeq ($(TARGET_PLATFORM),android-7)
    LOCAL_CFLAGS   += -DANDROID7
else
ifeq ($(TARGET_PLATFORM),android-8)
    LOCAL_CFLAGS   += -DAndroid8
else
ifeq ($(TARGET_PLATFORM),android-9)
    LOCAL_CFLAGS   += -DANDROID9
endif
endif
endif

Invalid Sign

#if defined( ANDROID9 )
   // do stuff for API Level 9
#endif

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>