Your Android App Has Native Code Even If You Never Wrote C++
Hidden .so files in ML and media libraries can block your app from Google Play. Learn to check alignment, fix build configs, and ensure 16 KB page support before the February 2027 deadline.

Most developers assume their app has no native code because they never wrote a single line of C or C++. That assumption is the trap. Machine learning runtimes, video and audio libraries, database engines, image codecs, and some analytics SDKs all ship .so files. If one of these dependencies was built for 4 KB pages only, your app is not compliant with Google Play requirements, even if you did not write the native code yourself.
The requirement is strict: starting February 1, 2027, if your app updates do not support 16 KB memory page sizes, you will not be able to release them. For pure Kotlin or Java apps, this is not an issue. However, for any app with native code hidden inside a library, it can become a hard block on releasing updates. The following sections explain how to identify these hidden dependencies, verify their alignment, and apply the necessary fixes to your build configuration.
The Trap: Hidden Native Dependencies
The core misconception is that you are responsible only for the code you write. In reality, modern Android development relies heavily on third-party libraries that include precompiled native binaries. These .so files often go unnoticed during initial setup because they are bundled automatically with the app.
Google Play now requires all apps targeting Android 15 (API level 35) and higher to support 16 KB memory page sizes on 64-bit devices. While pure Kotlin and Java applications already support these devices, any native code must be aligned correctly. A shared library loaded into memory in segments must have each segment start on a 16 KB boundary. If a library is linked for 4 KB pages, its segments start on 4 KB boundaries, which can cause the library to fail to load or crash on newer devices.
The warning often appears in Play Console on someone else's code, not yours. This means you must audit your entire dependency tree, not just your source files. The deadline is fixed: February 1, 2027. After this date, non-compliant updates cannot be released to users.
Step 1: Identify and Verify Native Code Alignment
Before attempting any fixes, you must determine if your app contains native code and whether it is properly aligned. Android Studio provides a quick way to check this. Open Build > Analyze APK and select your release APK. Look in the lib folder. If it is missing or empty, the app has no native code, and you are done. If there are .so files, the Alignment column shows a warning for each file with an alignment problem. Android Studio and lint also flag prebuilt libraries that are not 16 KB aligned.
For a more rigorous verification, especially in a CI environment, you should check every library from the command line. You can unpack the APK and inspect the LOAD segments using tools from the SDK. Any LOAD line with align 213, 212, or lower indicates a library that needs rebuilding or replacing. The zipalign check ensures the package itself is stored correctly, ending with "Verification successful" when every library is aligned properly.
The following commands demonstrate how to perform these checks:
# 1. Unpack the APK
unzip -q app-release.apk -d /tmp/apk_out
# 2. Each LOAD segment must show align 2**14 (16 KB) or more
NDK_BIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
for so in /tmp/apk_out/lib/arm64-v8a/*.so /tmp/apk_out/lib/x86_64/*.so; do
[ -f "$so" ] || continue
echo "$so"
"$NDK_BIN/llvm-objdump" -p "$so" | grep LOAD
done
# 3. Zip alignment of the APK itself (Build-Tools 35.0.0 or newer)
"$ANDROID_HOME"/build-tools/35.0.0/zipalign -v -c -P 16 4 app-release.apk
For App Bundles, use bundletool to check the configuration:
bundletool dump config --bundle=app-release.aab | grep alignment
PAGE_ALIGNMENT_16K means the bundle asks for 16 KB zip alignment, while PAGE_ALIGNMENT_4K indicates that APKs built from it will have 4 KB aligned .so files.
Step 2: Fix the Build Configuration
The guide offers a straightforward path to compliance if you update your build tools. With AGP 8.5.1 or higher, NDK r28 or higher, and 16 KB compatible prebuilt dependencies, your app is 16 KB compatible by default. You must keep AGP current and ensure uncompressed packaging is used, as 16 KB devices require uncompressed shared libraries on a 16 KB zip-aligned boundary.
For your own C and C++ code, NDK r28 and later compile 16 KB aligned by default. You should pin the version in Gradle so every machine uses the same one:
android {
// NDK r28+ produces 16 KB aligned libraries by default
ndkVersion = "28.2.13676358"
}
If you are stuck on NDK r27 or older, you must add specific linker flags. With CMake, use:
target_link_options(${CMAKE_PROJECT_NAME} PRIVATE
"-Wl,-z,max-page-size=16384"
"-Wl,-z,common-page-size=16384")
With ndk-build, add this to Android.mk:
LOCAL_LDFLAGS += -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384
For prebuilt libraries from third parties, you cannot relink a binary you do not build. You must update the dependency to a version whose release notes say it supports 16 KB pages, or replace it entirely. The guide states that prebuilt shared libraries must be recompiled the same way and re-imported.
If you cannot upgrade AGP to 8.5.1 or higher, the guide suggests having Gradle compress the shared libraries by setting useLegacyPackaging = true. However, this is only a workaround for packaging; it does not fix a library whose ELF segments are 4 KB aligned. Furthermore, compression causes the app to take more space once installed.
Step 3: Update Code and Test
Even with aligned libraries, native code that hard-codes the page size can still break. You must remove any code that relies on the PAGE_SIZE constant or assumes pages are 4096 bytes. Instead, use getpagesize() or sysconf(_SC_PAGESIZE). Review mmap() calls and other APIs that need page-aligned arguments. Check custom memory allocators if you have any.
Finally, test the app on a 16 KB environment. Use an Android Emulator system image with 16 KB page size. Confirm the environment first:
adb shell getconf PAGE_SIZE # should print 16384
Then exercise every feature that touches native code, such as ML models, video exports, and database operations. A library that loaded fine on 4 KB pages but crashes here is exactly what this step is designed to catch. Run these checks on every release build and fail the job if any LOAD segment is below 2**14.
Checklist
- You know whether the release APK contains any .so files, including from libraries
- AGP 8.5.1 or newer (AGP 9.4.0 at the time of writing) and NDK r28 or newer, pinned with ndkVersion
- Every arm64-v8a and x86_64 library shows LOAD alignment 2**14 or higher
- zipalign -c -P 16 reports "Verification successful"
- No native code assumes a 4096-byte page
- The app tested on a 16 KB emulator image (getconf PAGE_SIZE = 16384)
- Done before February 1, 2027, when non-compliant updates can no longer be released