I'm an partially sighted programmer who is far happier with a command line than an IDE, and finds IDE build systems very confusing. I'm successfully building shared libraries using the Android NDK from C and C++ code.
How do I make my shared libraries compatible with 16KB memory pages?
From November 1st 2025, new and updated Android apps must be compatible with 16KB memory pages, in addition to the classic 4KB memory pages, to be listed on Google Play. That requirement breaks down like this:
Apps that are entirely written in Java, Kotlin, or other languages that run on ART ("Android Run Time") are automatically compatible.
Apps that use SDKs which include native code libraries will need updated versions of those SDKs with 16KB-compatible native code libraries. If one of those SDKs is no longer being updated, you have a problem.
If you produce native code libraries for Android, you need to release new versions that are 16KB-compatible. Your existing ones won't be except by very unlikely accident.
Devices with 32-bit CPUs will only ever use 4KB pages, so 16KB compatibility is only relevant for 64-bit native code libraries. But 16KB compatibility is effectively compulsory for them.
There's no need to produce two 64-bit versions. If you provide both 32-bit and 64-bit libraries, you only need to change the 64-bit ones.
Usually, none. If your native code uses the system memory page size, either by hard-coding it or by using the PAGE_SIZE macro, you'll need to change that to use getpagesize() or sysconf(_SC_PAGESIZE). Then look for uses of mmap() and other calls that require page-aligned arguments, and change them.
Add -Wl,-z,max-page-size=16384 to your linking command. If you use C++, you'll need to use the C++ run-time library from NDK27 or later. Earlier ones aren't 16KB-compatible.
With the NDK tools on your path, run:
llvm-objdump -p /path/to/your/native/library.so | grep LOAD
Alignment of 2**12 is 4KB-compatible and not 16KB-compatible.
Alignment of 2**14 is 16KB-compatible, and also 4KB-compatible.