Skip to content

Android: Add 16KB page alignment for Android 15+ compatibility #33

@LightSideMeowshop

Description

@LightSideMeowshop

Problem

Native libraries built for Android need to be 16KB page-aligned to work correctly on Android 15+ devices. Currently, the Android build workflow does not include the necessary linker flags, which results in this warning during Unity builds:

Plugin 'libfreetype.so' is not 16KB-aligned. This may cause issues on ARM64 devices running Android 15+.

Solution

Add the following CMake flag to the Android build configuration:

-DCMAKE_SHARED_LINKER_FLAGS="-Wl,-z,max-page-size=16384"

Suggested change for .github/workflows/android.yml:

- name: Configure CMake (${{ matrix.platform.abi }})
  run: >
    cmake -B build
    -DCMAKE_TOOLCHAIN_FILE=$(dirname $(which ndk-build))/build/cmake/android.toolchain.cmake
    -DANDROID_ABI=${{ matrix.platform.abi }}
    -DBUILD_SHARED_LIBS=1
    -DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=1
    -DCMAKE_DISABLE_FIND_PACKAGE_PNG=1
    -DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=1
    -DCMAKE_DISABLE_FIND_PACKAGE_BZip2=1
    -DCMAKE_DISABLE_FIND_PACKAGE_BrotliDec=1
    -DCMAKE_SHARED_LINKER_FLAGS="-Wl,-z,max-page-size=16384"

References

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