Prepare Your App: 16KB Page Size Becomes Mandatory for Android 15+
“Starting with Android 15, all apps must support 16KB page sizes for compatibility with new device configurations.” — Android Developers Blog
This year, Google is enforcing certain settings on Android apps, such as removing forced portrait layout and requiring compatibility with 16KB memory page sizes. Until now, all Android devices managed memory in 4KB page sizes. Technology has advanced and now devices have larger memories. In order to benefit from this improved hardware, Android needs to adapt 16KB page size. Think of it like this: using 4KB pages on powerful hardware is like driving a Ferrari in a school zone, you’ve got the performance, so why not use it?
Some benefits of 16KB page size identified by Google:
Lower app launch times while the system is under memory pressure: 3.16% lower on average, with more significant improvements (up to 30%) for some apps that we tested
Reduced power draw during app launch: 4.56% reduction on average
Faster camera launch: 4.48% faster hot starts on average, and 6.60% faster cold starts on average
Improved system boot time: improved by 8% (approximately 950 milliseconds) on average
Is your app compatible with 16KB page size?
There are 3 types of apps:
Apps with no native code or library
✅ In this case your app is automatically compatible. You don’t need to do anything.
Apps that use 3rd party native code libraries
🔄 In this case, you need to update your dependencies with the ones that support 16KB page size. More info later.
Apps that has native code
🔧 In this case, you need to change your compiling parameters.
3rd Party Libraries with Native Code
Some of the 3rd party libraries that you use may have native code or native libraries. Then you need to update them with the versions that supports 16KB page size.
Firstly, check your APK with APK Analyzer tool in Android Studio from top bar menu Build > Analyze APK.
It will list the native libraries used in the app under lib folder. The files with .so extensions are the native libraries. You need to check the .so files under arm64-v8a and x86_64 folders.
Then check the 16KB page size compatibility with this script. This script will list the .so files as ALIGNED or UNALIGNED.
The ones with ALIGNED are ok, nothing needs to be done. The ones with UNALIGNED needs to be updated. Some libraries such as React-Native, Realm etc… use native code. For instance, you need to update the React-Native to at least 0.77 because 16KB page size compatibility starts with this version.
Usually, you can understand which of your libraries use the listed .so file from the name. However, sometimes it is not clear. In that case, search the .so file under your gradle cache folder which is a hidden folder in macos with the name “~/.gradle” under your home folder. Then you will see which library use that .so file there.
After updating the library version, check with this script again.
Apps with Native Code
You may have a native code in the app either with a native library or with a native code. Then upgrade to AGP version 8.5.1 or higher. NDK version r28 and higher compile 16 KB-aligned by default. To support compiling 16 KB-aligned shared libraries with Android NDK version r27 and higher, you need to update your build files.
Native Libraries
If you are using a native library such as open ssl, then you need to compile it with these parameters:
-Wl,-z,max-page-size=16384
Also, you need to check the native library code whether it has hardcoded 4KB page size usages. Usually there is a constant for that:
PAGE_SIZE = 4096
Find these constant and replace it with getpagesize()
or sysconf(_SC_PAGESIZE)
.
build.gradle
In the build.gradle you need to add this:
android {
...
defaultConfig {
...
// This block is different from the one you use to link Gradle
// to your CMake or ndk-build script.
externalNativeBuild {
// For ndk-build, instead use the ndkBuild block.
cmake {
// Passes optional arguments to CMake.
arguments += listOf("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
}
}
}
}
ndk-build
In your Application.mk, you need to add this:
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true
Test Your App with 16KB Page Sized Emulator
After fixing everything, then you can test your app with a 16KB page size based emulator.
If your app is not 16KB page size compatible, you will get a popup like this one:
Hope this guide helps you in fixing 16KB page size compatibility.
References:
https://developer.android.com/guide/practices/page-sizes
Keep reading with a 7-day free trial
Subscribe to Android Devs Substack to keep reading this post and get 7 days of free access to the full post archives.