DEV Community

222 Nin
222 Nin

Posted on

Zero-Dependency Python Script to Verify Google Play 16 KB ELF Page-Size Alignment on .aab Bundles

When shipping native or mixed Android App Bundles (.aab) targeting Android 15/16 (API 35–36), one unaligned 64-bit .so library with PT_LOAD p_align < 16384 is enough to trigger Google Play Console compatibility warnings—or outright crashes on 16 KB page-size ARM64 devices.

While preparing 14 offline-first Android games & utilities at Lucci Digital Studio, we wanted a fast, zero-dependency Python pre-flight script that inspects every .so ELF header directly inside a signed .aab or .apk without unpacking gigabytes of NDK toolchains in CI.

Inspecting ELF PT_LOAD Segments Inside .aab

Every 64-bit ELF binary (arm64-v8a / x86_64) stores its program header table offset e_phoff at byte 32. Each PT_LOAD (p_type == 1) entry ends with an 8-byte p_align field:

import struct, zipfile

def check_aab_16kb(aab_path):
    with zipfile.ZipFile(aab_path, "r") as zf:
        for name in zf.namelist():
            if not name.endswith(".so"):
                continue
            blob = zf.read(name)
            if blob[:4] != b"\x7fELF" or blob[4] != 2:  # 64-bit ELF
                continue
            phoff = struct.unpack_from("<Q", blob, 32)[0]
            entsize, phnum = struct.unpack_from("<HH", blob, 54)
            aligns = [
                struct.unpack_from("<IIQQQQQQ", blob, phoff + i * entsize)[7]
                for i in range(phnum)
                if struct.unpack_from("<I", blob, phoff + i * entsize)[0] == 1
            ]
            if ("/arm64-v8a/" in name or "/x86_64/" in name) and any(a < 16384 for a in aligns):
                raise AssertionError(f"{name} failed 16 KB alignment: min={min(aligns)}")
Enter fullscreen mode Exit fullscreen mode

Grab the Full Open-Source CLI + Join Our 14-Day Mutual Android Playtest!

We published the full standalone CLI (which also checks Google Play's strict 30 / 80 / 4000 store-listing character limits and SHA-256 release records):

Top comments (0)