fix(android): align native libs to 16 KB pages#30
Merged
Conversation
Pass -extldflags=-Wl,-z,max-page-size=16384 to gomobile bind so the emitted .so libraries use 16 KB ELF page alignment. Android 15 devices can run with 16 KB memory pages and Google Play rejects bundles whose native code is only 4 KB aligned. The prebuilt arm64-v8a libgojni.so in android/libs/api.aar was 4 KB aligned (p_align 0x1000) and is now 0x4000. Regenerated android/libs/api.aar via run_build_tool_android.sh.
2 tasks
TaprootFreak
added a commit
to RealUnitCH/app
that referenced
this pull request
Jun 9, 2026
) ## Why Google Play flags the app bundle: its native code is not 16 KB page aligned, so it cannot run on Android 15+ devices that use 16 KB memory pages. The only offending library was `libgojni.so` (the gomobile-built Go binding shipped by `bitbox_flutter`) — its arm64-v8a `PT_LOAD` segments were `p_align = 0x1000` (4 KB). Every other native lib in the bundle (libflutter, libapp, libsqlite3mc, libtensorflowlite_jni, …) is already ≥ 16 KB. ## What Bump `bitbox_flutter` `v0.0.8 → v0.0.9`. v0.0.9 rebuilds the gomobile binding with `-extldflags=-Wl,-z,max-page-size=16384`, producing 16 KB-aligned `.so` libraries. See DFXswiss/bitbox_flutter#30. `pubspec.lock` updated to the v0.0.9 commit (`6172a2e`); no other lock entries change. ## Verification - `bitbox_flutter` v0.0.9 `jni/arm64-v8a/libgojni.so` + `x86_64`: `p_align` `0x1000` → **`0x4000`** (16 KB) - API-safe bump: javap public signatures (146 lines) and exported dynamic symbols (284) are **byte-identical** between v0.0.8 and v0.0.9 — only ELF alignment changed, so no source-level impact - `bitbox_flutter` PR gate green (go vet/test, dart format, analyze, flutter test) ## Test plan - [ ] App CI green (Analyze & Test, Visual Regression, Coverage Floor Gate) - [ ] Release build: confirm `lib/arm64-v8a/libgojni.so` reports 16 KB alignment in the final AAB and the Play Console warning clears
TaprootFreak
added a commit
that referenced
this pull request
Jun 9, 2026
Brings in #30's 16 KB page-alignment fix. The api.aar conflict is resolved by rebuilding the gomobile binding with BOTH the 16 KB alignment flag (-extldflags=-Wl,-z,max-page-size=16384, from the merged build script) AND the new DeviceStatus export, so the merged artefact keeps Android 15+ support and exposes the device status. libgojni.so PT_LOAD p_align verified at 0x4000.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Google Play flags the RealUnit wallet bundle: its native code is only 4 KB page aligned, so it cannot run on Android 15+ devices that use 16 KB memory pages. The offending library is
libgojni.so(the gomobile-built Go binding shipped inandroid/libs/api.aar) — its arm64-v8aPT_LOADsegments hadp_align = 0x1000(4 KB). Every other native lib in the app (libflutter, libapp, libsqlite3mc, tensorflowlite, …) is already ≥ 16 KB;libgojni.sowas the only 4 KB outlier.Fix
Pass
-extldflags=-Wl,-z,max-page-size=16384togomobile bindinrun_build_tool_android.sh. The flag reaches the NDK linker (lld) and forces 16 KB ELF page alignment. NDK r27 does not default to 16 KB, so the explicit flag is required.android/libs/api.aarregenerated with the flag.Verification
jni/arm64-v8a/libgojni.soPT_LOADp_align:0x1000→0x4000(16 KB)go vet,go test -race(api + u2fhid),dart format --set-exit-if-changed,flutter analyze,flutter test(11 passed)Test plan
bitbox_flutterref in the RealUnit app, rebuild the AAB, and confirmlib/arm64-v8a/libgojni.soreports 16 KB alignment in the final bundle