--- a/libbase/logging.cpp
+++ b/libbase/logging.cpp
@@ -209,9 +209,9 @@
 static std::string* gDefaultTag;
 
 void SetDefaultTag(const std::string& tag) {
-  if (__builtin_available(android 30, *)) {
+#if defined __ANDROID__ && __ANDROID_API__ >= 30
     __android_log_set_default_tag(tag.c_str());
-  } else {
+#else
     std::lock_guard<std::recursive_mutex> lock(TagLock());
     if (gDefaultTag != nullptr) {
       delete gDefaultTag;
@@ -220,7 +220,7 @@
     if (!tag.empty()) {
       gDefaultTag = new std::string(tag);
     }
-  }
+#endif
 }
 
 static bool gInitialized = false;
@@ -314,13 +314,13 @@
   int32_t lg_id = LogIdTolog_id_t(id);
   int32_t priority = LogSeverityToPriority(severity);
 
-  if (__builtin_available(android 30, *)) {
+#if defined __ANDROID__ && __ANDROID_API__ >= 30
     __android_log_message log_message = {sizeof(__android_log_message),     lg_id, priority, tag,
                                          static_cast<const char*>(nullptr), 0,     message};
     __android_log_logd_logger(&log_message);
-  } else {
+#else
     __android_log_buf_print(lg_id, priority, tag, "%s", message);
-  }
+#endif
 }
 
 LogdLogger::LogdLogger(LogId default_log_id) : default_log_id_(default_log_id) {}
@@ -396,7 +396,7 @@
   LogFunction old_logger = std::move(Logger());
   Logger() = std::move(logger);
 
-  if (__builtin_available(android 30, *)) {
+#if defined __ANDROID__ && __ANDROID_API__ >= 30
     __android_log_set_logger([](const struct __android_log_message* log_message) {
       auto log_id = log_id_tToLogId(log_message->buffer_id);
       auto severity = PriorityToLogSeverity(log_message->priority);
@@ -404,7 +404,7 @@
       Logger()(log_id, severity, log_message->tag, log_message->file, log_message->line,
                log_message->message);
     });
-  }
+#endif
   return old_logger;
 }
 
@@ -412,9 +412,9 @@
   AbortFunction old_aborter = std::move(Aborter());
   Aborter() = std::move(aborter);
 
-  if (__builtin_available(android 30, *)) {
+#if defined __ANDROID__ && __ANDROID_API__ >= 30
     __android_log_set_aborter([](const char* abort_message) { Aborter()(abort_message); });
-  }
+#endif
   return old_aborter;
 }
 
@@ -500,11 +500,11 @@
 
   // Abort if necessary.
   if (data_->GetSeverity() == FATAL) {
-    if (__builtin_available(android 30, *)) {
+#if defined __ANDROID__ && __ANDROID_API__ >= 30
       __android_log_call_aborter(msg.c_str());
-    } else {
+#else
       Aborter()(msg.c_str());
-    }
+#endif
   }
 }
 
@@ -515,11 +515,11 @@
 void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity severity, const char* tag,
                          const char* message) {
   int32_t priority = LogSeverityToPriority(severity);
-  if (__builtin_available(android 30, *)) {
+#if defined __ANDROID__ && __ANDROID_API__ >= 30
     __android_log_message log_message = {
         sizeof(__android_log_message), LOG_ID_DEFAULT, priority, tag, file, line, message};
     __android_log_write_log_message(&log_message);
-  } else {
+#else
     if (tag == nullptr) {
       std::lock_guard<std::recursive_mutex> lock(TagLock());
       if (gDefaultTag == nullptr) {
@@ -530,38 +530,38 @@
     } else {
       Logger()(DEFAULT, severity, tag, file, line, message);
     }
-  }
+#endif
 }
 
 LogSeverity GetMinimumLogSeverity() {
-  if (__builtin_available(android 30, *)) {
+#if defined __ANDROID__ && __ANDROID_API__ >= 30
     return PriorityToLogSeverity(__android_log_get_minimum_priority());
-  } else {
+#else
     return gMinimumLogSeverity;
-  }
+#endif
 }
 
 bool ShouldLog(LogSeverity severity, const char* tag) {
   // Even though we're not using the R liblog functions in this function, if we're running on Q,
   // we need to fall back to using gMinimumLogSeverity, since __android_log_is_loggable() will not
   // take into consideration the value from SetMinimumLogSeverity().
-  if (__builtin_available(android 30, *)) {
+#if defined __ANDROID__ && __ANDROID_API__ >= 30
     int32_t priority = LogSeverityToPriority(severity);
     return __android_log_is_loggable(priority, tag, ANDROID_LOG_INFO);
-  } else {
+#else
     return severity >= gMinimumLogSeverity;
-  }
+#endif
 }
 
 LogSeverity SetMinimumLogSeverity(LogSeverity new_severity) {
-  if (__builtin_available(android 30, *)) {
+#if defined __ANDROID__ && __ANDROID_API__ >= 30
     int32_t priority = LogSeverityToPriority(new_severity);
     return PriorityToLogSeverity(__android_log_set_minimum_priority(priority));
-  } else {
+#else
     LogSeverity old_severity = gMinimumLogSeverity;
     gMinimumLogSeverity = new_severity;
     return old_severity;
-  }
+#endif
 }
 
 ScopedLogSeverity::ScopedLogSeverity(LogSeverity new_severity) {
