fix: add 16KB page alignment support for Android#182
Open
Obehi234 wants to merge 1 commit intoLtbLightning:mainfrom
Open
fix: add 16KB page alignment support for Android#182Obehi234 wants to merge 1 commit intoLtbLightning:mainfrom
Obehi234 wants to merge 1 commit intoLtbLightning:mainfrom
Conversation
Disable precompiled binaries which are built with 4KB page alignment. Google Play requires 16KB alignment for Android 15+ (API 35+). Building from source with NDK r28+ produces correct alignment. Also adds explicit linker flags in .cargo/config.toml as a safety net for builds outside of Cargokit. Closes LtbLightning#181
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.
Summary
Google Play now requires 16KB page alignment (
0x4000) for native libraries targeting Android 15+ (API 35+). The current precompiled binaries shipped via Cargokit are built with 4KB alignment (0x1000), causing Play Store rejection.This PR disables precompiled binary downloads to force source builds, which produce correct 16KB alignment when using NDK r28+.
Closes #181
Investigation & Root Cause
How Cargokit Resolves Binaries
Cargokit computes a SHA-256 hash of the Rust source files (
src/*.rs,Cargo.toml,Cargo.lock,cargokit.yaml) and uses it to look up precompiled binaries from theurl_prefixincargokit.yaml. If a matching binary is found, it's downloaded and used directly. Source compilation only happens as a fallback.The Problem
The precompiled binaries hosted at
https://github.com/LtbLightning/bdk-flutter/releases/download/precompiled_were built with an older NDK that defaults to 4KB page alignment. We verified this by downloading theaarch64-linux-androidrelease artifact and inspecting it:Why .cargo/config.toml Alone Doesn't Fix It
During Flutter builds, Cargokit sets
CARGO_ENCODED_RUSTFLAGSinandroid_environment.dart. This environment variable overrides all other rustflags sources, including.cargo/config.toml. So adding linker flags there only helps standalonecargo buildinvocations, not Flutter builds through Cargokit.The actual 16KB alignment in Flutter builds comes from NDK r28+ defaulting to it in its linker.
Changes
rust/cargokit.yamlprecompiled_binariesto force source buildsrust/.cargo/config.tomlVerification
0x1000(4KB)0x4000(16KB)Tested end-to-end: built a Flutter app depending on bdk-flutter with this change, extracted
libbdk_flutter.sofrom the APK, and confirmed0x4000alignment viallvm-readelf -l.Tradeoffs
precompiled_binariessection. The config is commented out (not removed) to make this easy.