Android 16KB alignment

Hi, so I’m seeing a message when I run on Android emulator about the app not being 16 KB compatible. I look at a past forum post about this and it seemed to suggest that this was fixed by using NDK 28. I have a fork of lime which is up to date with the develop branch, but noticed there are some changes in 8.3.0-dev which address this.

However, even though I am using NDK 28 and I have rebuilt lime, I’m still seeing this message… is there anything else I need to do?

Thanks,
Greg

Hi Greg,

After changing ndk version, please make sure to do a clean rebuild of lime binaries (lime rebuild android -clean) and of your project.

You can add the -DHXCPP_VERBOSE flag to the build to ensure that hxcpp is using the correct ndk version.

Additionally, after the Lime rebuild with -clean, it’s probably a good idea to build your app with -clean too. Just to be sure that nothing gets reused from previous builds.

To see the path to the version of the NDK that Lime thinks it should use, you can also run lime config ANDROID_NDK_ROOT in a terminal.

Ah, I was so sure I had done that! No problems, it works fine now. Thanks guys.

I can’t get it to work so far.
I rebuilt lime with ndk28, so when I do

llvm-objdump -p c:\HaxeToolkit\haxe\lib\lime\git\ndll\Android\liblime-64.so

It tells that library is ok:

    LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**14
    LOAD off    0x00000000003a25f0 vaddr 0x00000000003a65f0 paddr 0x00000000003a65f0 align 2**14
    LOAD off    0x00000000008d4db0 vaddr 0x00000000008dcdb0 paddr 0x00000000008dcdb0 align 2**14
    LOAD off    0x0000000000910b70 vaddr 0x000000000091cb70 paddr 0x000000000091cb70 align 2**14

But for 32bit library it is not:

llvm-objdump -p c:\HaxeToolkit\haxe\lib\lime\git\ndll\Android\liblime-v7.so

    LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12
    LOAD off    0x002804e0 vaddr 0x002814e0 paddr 0x002814e0 align 2**12
    LOAD off    0x007eae80 vaddr 0x007ece80 paddr 0x007ece80 align 2**12
    LOAD off    0x0080d010 vaddr 0x00810010 paddr 0x00810010 align 2**12

And then when I test my apk with 64bit aligned library it tells me this library is not good:

zipalign.exe -v -c -P 16 4 myapk64.apk
Verifying alignment of myapk64.apk (4)...
      87 META-INF/com/android/build/gradle/app-metadata.properties (OK - compressed)
     178 classes.dex (OK - compressed)
   49152 lib/arm64-v8a/libApplicationMain.so (OK)
17731584 lib/arm64-v8a/liblime.so (BAD - 4096)

I have even extracted this liblime.so from my apk and tested it again, and it is aligned.

Maybe someone can tell me how to fix this issue?
Should 32bit library be also aligned?
Thank you.

According to Android: Support 16 KB page sizes, this new requirement is specifically for 64-bit.

Starting November 1st, 2025, all new apps and updates to existing apps submitted to Google Play and targeting Android 15+ devices must support 16 KB page sizes on 64-bit devices.

I see this on the same page:

16 KB devices require apps that ship with uncompressed shared libraries to align them on a 16 KB zip-aligned boundary. To do this, you need to upgrade to Android Gradle Plugin (AGP) version 8.5.1 or higher.

It’s worth noting that, on the develop branch, we’re still on an older version of AGP than the one specified on that page. So if you happened to try NDK r28 with the develop branch (or a released 8.2 or older version of Lime), that might not be enough. You might also need to customize which Gradle and AGP versions you are using (which can be done in project.xml).

This will make it match what’s currently specified in the 8.3.0-Dev branch:

<config:android gradle-version="8.9" gradle-plugin="8.7.3" />
1 Like

Thank you, Josh!
Yes, I was using older gradle.