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.

Have updated lime/hxcpp to git dev versions, NDK to 29, got:

Link: libApplicationMain-v7.so
ld.lld: error: cannot open crtbegin_so.o: No such file or directory
ld.lld: error: unable to find library -llog
ld.lld: error: unable to find library -lc++
ld.lld: error: cannot open crtend_so.o: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Do you have any suggestion what could be wrong?
I also had tried NDK 28 but it cant even compile with something like
“Error redefining symbol…”

I can both rebuild the Lime binaries for Android, and build an Android app using both NDK 28 and 29.


How are you installing your NDKs? From inside Android Studio? If so, then the NDKs should be installed inside the Android SDK, with each NDK being named by its own version number. On my macOS machine, this is where NDK 29 was installed:

/Users/USERNAME/Library/Android/sdk/ndk/29.0.14206865

That is the exact path (except using my own username) that I passed to Lime when configuring ANDROID_NDK_ROOT for Android builds. To be clear, the parent ndk directory is not the correct path because there are multiple NDKs in sub-directories inside there.

Windows and Linux paths will be slightly different, of course, but I would assume still somewhere within your home directory and eventually ending similarly.

If you downloaded the NDK a different way, I’m not sure that I can give much advice. It generally easiest to get any recent version of the NDK from Android Studio these days.


When you checked out Lime dev, you ran the appropriate lime rebuild [whatever] commands (including android), right?


When you tried switching NDKs, did you do -clean builds of everything? Sometimes, compiling seems to use cached stuff from previous builds, and when there’s a mix of cached and new stuff, you can get weird errors.

My bad, it seems trying ndk 28 I’m exactly forgot to set -clean rebuilding lime for android. And with 28, it seems to be working now. So I’ll try n29 another time.
During upgrade I also had to update jdk 11 to 17 and minSdkVersion 19 to 21 (it is sad, I’d rather prefer to stay with 19 since I still have android 5 devices)…
Thank you, and sorry for bothering!