Skip to content

fix(android): apply 16kb alignment config in native asset builds#90

Merged
reez merged 4 commits into
bitcoindevkit:mainfrom
reez:fix-88
Jun 25, 2026
Merged

fix(android): apply 16kb alignment config in native asset builds#90
reez merged 4 commits into
bitcoindevkit:mainfrom
reez:fix-88

Conversation

@reez

@reez reez commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

That PR does three things to address #88

  • Updates hook/build.dart to pass native/.cargo/config.toml explicitly to Cargo, so the 16 KB Android linker flags are applied during the Flutter Native Assets build.
  • Adds CI coverage for NDK 27 alignment, including a hook-path smoke check, so we prove the fix works through the path that previously missed the Cargo config.
  • Adds Dart scripts to inspect the built Android .so/APK ELF load alignment and fail if libbdk_dart_ffi.so is not 16 KB aligned.

@Johnosezele Johnosezele left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good, I've left some nits below.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit here: This handles .so and APK but not AAB. Not urgent since the hook job checks the .so directly, but if someone wants to sanity check a Play upload bundle down the road, that'd be a nice add.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I see what your saying, is the 6c06f6f commit I added doing what you were thinking you'd want?

@Johnosezele Johnosezele Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does.

Comment thread .github/workflows/ci.yml Outdated
Comment on lines +154 to +163
rustup toolchain install 1.85.1 --profile minimal --target aarch64-linux-android
NDK="$ANDROID_HOME/ndk/27.1.12297006"
TOOLCHAIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64"
export ANDROID_NDK_HOME="$NDK"
export ANDROID_NDK_ROOT="$NDK"
export AR_aarch64_linux_android="$TOOLCHAIN/bin/llvm-ar"
export CC_aarch64_linux_android="$TOOLCHAIN/bin/aarch64-linux-android35-clang"
export CXX_aarch64_linux_android="$TOOLCHAIN/bin/aarch64-linux-android35-clang++"
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$TOOLCHAIN/bin/aarch64-linux-android35-clang"
export BINDGEN_EXTRA_CLANG_ARGS_aarch64_linux_android="--sysroot=$TOOLCHAIN/sysroot -I$TOOLCHAIN/sysroot/usr/include/aarch64-linux-android"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should test both arm64-v8a and x86_64

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I added x86_64 coverage in new commit 8c2154f alongside arm64 so the alignment job now verifies both Android 64-bit ABIs.

Comment thread .github/workflows/ci.yml
Comment on lines 124 to 126
- name: Build Android debug APK (bdk_demo)
working-directory: bdk_demo
run: flutter build apk --debug --target-platform android-arm64

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, let's verify alignment on the built apk

Suggested change
run: flutter build apk --debug --target-platform android-arm64
- name: Build Android debug APK (bdk_demo)
working-directory: bdk_demo
run: flutter build apk --debug --target-platform android-arm64
- name: Verify APK ELF alignment
run: dart scripts/check_android_elf_alignment.dart bdk_demo/build/app/outputs/flutter-apk/app-debug.apk

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I added a post-build APK check so android-smoke now verifies the packaged libbdk_dart_ffi.so in the Flutter debug APK. I didn’t apply the suggestion block exactly just because the build step already existed so I kept that in place and added only the verification step after it in 7d85229

@j-kon j-kon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 7d85229. The previous review feedback has been addressed, and the Android alignment checks look good.

@Johnosezele Johnosezele left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 7d85229 small nits have been resolved. Thanks!

@reez reez merged commit 686af14 into bitcoindevkit:main Jun 25, 2026
7 checks passed
@reez reez deleted the fix-88 branch June 25, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants