ShazamKit for Android and 16 KB native library alignment

Hello,

I'm working on a Flutter app targeting both Android and iOS, where I implemented ShazamKit.

In order to achieve that, I first tried with the flutter_shazam_kit package, but since it's not maintained anymore, I forked it here, and tried to update it to meet the Google Play Store requirements, as you can see here:

https://github.com/mregnauld/flutter_shazam_kit/tree/fix-16k

Unfortunately, after trying everything, my app still doesn't meet the (not so) new 16 KB native library alignment. Also, I'm 100% sure it comes from that because the error message disappears if I remove that package from my app.

So after investigating, it seems that the problem comes from the ShazamKit for Android (that you can find here: https://developer.apple.com/download/all/?q=Android%20ShazamKit), and especially the .so files in the .aar file.

Is there anything I can do to fix that, or should I wait before the ShazamKit team fix that?

I'm totally stuck with that so any help is highly appreciated.

Thanks.

Hi @Mattreg, ShazamKit for android 2.1.1 does support 16KB memory page addresses. In branch fix-16k you have correctly imported the latest ShazamKit for android version. I checked this via md5:a6426940b80c4ec5f18a644e4f59193f.

As good measure I have also explicitly verified your shazamKit .aar library for 16KB memory compatibility, and I confirm it's 16KB compatible. Steps:

  1. unzip the .aar, navigate to the jni folder
  2. run (adjust for your environment)
~/android-sdk/ndk/29.0.14033849/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objdump -p libsigx.so  | grep LOAD
    LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**14
    LOAD off    0x000000000005afe0 vaddr 0x000000000005efe0 paddr 0x000000000005efe0 align 2**14
    LOAD off    0x000000000005bca0 vaddr 0x0000000000063ca0 paddr 0x0000000000063ca0 align 2**14

2**14 is means it is supporting 16KB pages , see https://developer.android.com/guide/practices/page-sizes.

  1. I did also run
~/android-sdk/build-tools/36.0.0/zipalign -v -c -P 16 4 ~/Downloads/shazamkit-android-release.aar

Verifying alignment of ~/Downloads/shazamkit-android-release.aar (4)...
 [REDACTED]
  344222 jni/ (OK - compressed)
 344270 jni/armeabi-v7a/ (OK - compressed)
 344328 jni/armeabi-v7a/libsigx.so (OK - compressed)
 543451 jni/armeabi-v7a/libc++_shared.so (OK - compressed)
 892535 jni/x86/ (OK - compressed)
 892585 jni/x86/libsigx.so (OK - compressed)
1127399 jni/x86/libc++_shared.so (OK - compressed)
1564816 jni/arm64-v8a/ (OK - compressed)
1564872 jni/arm64-v8a/libsigx.so (OK - compressed)
1791270 jni/arm64-v8a/libc++_shared.so (OK - compressed)
2197874 jni/x86_64/ (OK - compressed)
2197927 jni/x86_64/libsigx.so (OK - compressed)
2424638 jni/x86_64/libc++_shared.so (OK - compressed)
2840725 ATTRIBUTIONS (OK - compressed)
2848538 AndroidManifest.xml (OK - compressed)
2848809 R.txt (OK - compressed)
Verification successful

where Verification successful indicates compatibility.

  1. You mentioned

I'm 100% sure it comes from [ShazamKit] because the error message disappears if I remove that package from my app.

At which error message are you referring to?

Best.

Hello @francescoPe,

Thank you so much for your detailed answer!

Well I guess that's good news, then.

The error I'm referring to is shown in my Google Play Console:

So if the shazamkit.aar library is fine, it means the error is on my end.

Did you spot my mistake in my repo, by any chance?

https://github.com/mregnauld/flutter_shazam_kit/tree/fix-16k

Thanks a lot for your help!

For your info, I made some updates to my fix-16k branch.

Also, after investigating more (thanks to Claude Code), here what seems to happen:

  • ShazamKit AAR contains libraries with 16KB alignment (0x4000)
  • During Android build, these libraries are re-aligned to 4KB (0x1000)
  • The Android Gradle Plugin's strip/packaging process is changing the alignment

So, are we sure that ShazamKit Android AAR has been verified to work with AGP 8.5.1+ and maintains 16KB alignment through the full build process?

Maybe I missed something but at this point, I really don't know.

ShazamKit for Android and 16 KB native library alignment
 
 
Q