Skip to content

[Android] Native Crash: UnsatisfiedLinkError - Program alignment (4096) cannot be smaller than system page size (16384) Description #491

Description

@ngioldasis

Description

The application crashes on startup on Android 15 devices (and emulators) utilizing 16KB page size. The native linker rejects libvrapi.so (and other bundled native libraries) with a program alignment error.

Static analysis of the library binaries using readelf initially suggested proper 16KB alignment (0x4000), but the Android 15 linker still reports a failure at 4096. This suggests that while the LOAD segments are aligned, internal segments (such as PT_GNU_RELRO) or the overall ELF structure may still contain hardcoded 4KB assumptions incompatible with the 16KB page size requirement.

Environment

ViroReact Version: 2.57.2

Development OS: macOS

Target Android OS: Android 15 (API 35+)

Device(s): Android 16KB page size Emulator

Error Log

06-30 12:39:09.289 9555 9603 E linker : "/data/app/.../lib/arm64-v8a/libvrapi.so" program alignment (4096) cannot be smaller than system page size (16384)
06-30 12:39:09.291 9555 9603 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: "..." program alignment (4096) cannot be smaller than system page size (16384)

Technical Verification

I have performed a thorough inspection of the bundled binaries in viro_renderer-release.aar:

LOAD Segment Alignment: Extracted .so files show LOAD segments with 0x4000 (16KB) alignment.

Zip Alignment: Verified that the uncompressed libraries within the APK zip structure are on 16KB-aligned byte offsets.

Dependency Chain: All NEEDED dependencies are standard system libraries (libc.so, liblog.so, etc.).

Despite these libraries appearing compliant via readelf, the OS linker consistently reports a 4096-alignment conflict. This issue matches the behavior described in other NDK-heavy projects, where RELRO segment padding or other ELF-internal linker constraints are failing to meet the strict Android 15 requirements.

Proposed Action

The native libraries appear to have been compiled/linked using an older NDK toolchain default. They require a full re-build of the native layer using:

NDK r28+

Linker flag: -Wl,-z,max-page-size=16384

This needs to be applied consistently to all bundled native libraries, including libviro_renderer.so, libBulletCollision.so, and others, not just libvrapi.so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions