I want to differentiate code between Android Q and Android R how do I achieve this in Android.bp? In Android.mk I did something like this
ifeq ($(PLATFORM_VERSION), R)
LOCAL_CFLAGS += -DANDROID_R_AOSP
else
LOCAL_CFLAGS += -DANDROID_Q_AOSP
How to do above code in Android.bp?
Follow the instructions given here.
Replace this part in the my_defaults.go:
if ctx.AConfig().Getenv("SOME_ENV_VAR") == "some_value" {
cflags = append(cflags, "-DCONDITIONAL")
}
With:
if ctx.AConfig().PlatformVersionName() == "R" {
cflags = append(cflags, "-DANDROID_R_AOSP")
} else {
cflags = append(cflags, "-DANDROID_Q_AOSP")
}
Reference: link. In older versions this function was called PlatformVersion() (link), but for Android 9 or higher you should be fine.
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