--- a/server/ucontext-portable.h
+++ b/server/ucontext-portable.h
@@ -4,7 +4,7 @@
 
 #pragma once
 
-#if defined(__x86_64__)
+#if defined(__x86_64__) && !defined(__ANDROID__)
 // for x86, we just use makecontext(), ucontext_t and other native functions
 #include <ucontext.h>
 
@@ -14,7 +14,8 @@
 #define makecontext_portable makecontext
 #define swapcontext_portable swapcontext
 
-#elif defined(__arm64__)
+#elif defined(__arm64__) || \
+      defined(__ANDROID__) && (defined(__aarch64__) || defined(__x86_64__))
 // for M1, we can't use native makecontext() and others: they compile, but hang up when called
 // instead, we require the ucontext library: https://github.com/kaniini/libucontext
 // see the docs: https://vkcom.github.io/kphp/kphp-internals/developing-and-extending-kphp/compiling-kphp-from-sources.html
