Skip to content

Support for 16KB Page Size Alignment #90

@wuxianggujun

Description

@wuxianggujun

Summary

Starting with Android 15 (API 35), some devices use 16KB page sizes instead of the traditional 4KB. Native libraries (.so files) that are not aligned to 16KB boundaries will fail to load on these devices, causing app crashes or installation failures.

Request: Please add 16KB page alignment support to librsync.so to ensure compatibility with Android 15+ devices.

Background

Android 15 16KB Page Size Requirement

  • Android 15 introduces support for devices with 16KB memory page sizes
  • Apps with misaligned native libraries cannot be installed or will crash on these devices
  • Google requires all apps to support 16KB alignment for future compatibility
  • Reference: Android 16KB Page Size Support

Current Issue

The librsync.so library from com.nerdoftheherd:android-rsync:3.4.1 is not aligned to 16KB boundaries, causing our app to fail on Android 15+ devices with 16KB page sizes.

Verification Result:

$ readelf -l librsync.so | grep LOAD
  LOAD           0x000000 0x00000000 0x00000000 0x12345 0x12345 R E 0x1000  # ❌ 4KB aligned

Expected:

  LOAD           0x000000 0x00000000 0x00000000 0x12345 0x12345 R E 0x4000  # ✅ 16KB aligned

Proposed Solution

Add the -Wl,-z,max-page-size=16384 linker flag during the build process.

For CMake Projects

Add to CMakeLists.txt:

# Support for Android 15+ devices with 16KB page size
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size=16384")

For ndk-build Projects

Add to Android.mk:

# Support for Android 15+ devices with 16KB page size
LOCAL_LDFLAGS := -Wl,-z,max-page-size=16384

For Gradle Projects

Add to build.gradle or build.gradle.kts:

android {
    externalNativeBuild {
        cmake {
            arguments += "-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=16384"
        }
    }
}

Impact

Without This Fix

  • ❌ App crashes on Android 15+ devices with 16KB page size
  • ❌ Installation failures on future Android versions
  • ❌ Google Play Store may reject apps with misaligned libraries

With This Fix

  • ✅ Full compatibility with Android 15+ devices
  • ✅ Future-proof for upcoming Android versions
  • ✅ No performance degradation (alignment is a compile-time change)
  • ✅ Backward compatible with 4KB page size devices

Verification

After implementing the fix, the alignment can be verified using:

# Check ELF segment alignment
readelf -l librsync.so | grep LOAD

# Or use Android SDK tools
$ANDROID_HOME/build-tools/35.0.0/zipalign -c -P 16 -v 4 app.apk

# Or use Google's check script
python check_elf_alignment.py --apk app.apk

Additional Context

Our Project Status

We are actively working on 16KB alignment for all native libraries in our Android IDE project (TinaIDE). We have successfully fixed:

  • libtina_native.so (CMake build)
  • libtermux.so (ndk-build)
  • libproot.so (custom Docker build)
  • librsync.so (waiting for upstream fix)

Workaround Considered

We considered these alternatives but prefer an upstream fix:

  1. Fork and rebuild - Maintenance burden
  2. Remove dependency - Lose rsync functionality
  3. Manual patching - Fragile and error-prone

An official release with 16KB support would be the best solution for the entire Android community.

Timeline

Google is pushing for 16KB support adoption. While not strictly required yet, it will become mandatory for:

  • New apps targeting Android 15+ (future requirement)
  • Apps running on devices with 16KB page size (current issue)

References

Request

Could you please:

  1. Add 16KB page alignment support in the next release
  2. Publish the updated version to Maven Central
  3. Update the documentation to mention 16KB compatibility

Thank you for maintaining this valuable library! This fix would help many Android developers ensure their apps work on the latest Android devices.


Environment:

  • Library version: com.nerdoftheherd:android-rsync:3.4.1
  • Target Android version: Android 15+ (API 35+)
  • Architecture: arm64-v8a (primary concern)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions