fix(android): apply 16kb alignment config in native asset builds#90
Conversation
Johnosezele
left a comment
There was a problem hiding this comment.
This is looking good, I've left some nits below.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
yeah I see what your saying, is the 6c06f6f commit I added doing what you were thinking you'd want?
| 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" |
There was a problem hiding this comment.
we should test both arm64-v8a and x86_64
There was a problem hiding this comment.
Agreed. I added x86_64 coverage in new commit 8c2154f alongside arm64 so the alignment job now verifies both Android 64-bit ABIs.
| - name: Build Android debug APK (bdk_demo) | ||
| working-directory: bdk_demo | ||
| run: flutter build apk --debug --target-platform android-arm64 |
There was a problem hiding this comment.
In addition, let's verify alignment on the built apk
| 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 |
There was a problem hiding this comment.
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
Johnosezele
left a comment
There was a problem hiding this comment.
ACK 7d85229 small nits have been resolved. Thanks!
That PR does three things to address #88
hook/build.dartto passnative/.cargo/config.tomlexplicitly to Cargo, so the 16 KB Android linker flags are applied during the Flutter Native Assets build..so/APK ELF load alignment and fail iflibbdk_dart_ffi.sois not 16 KB aligned.