build, qt, doc: Add Android GUI support and APK packaging
This PR restores cross-compilation for Android (previously removed in #30049 and proposed in #32262) and extends it to support the Bitcoin-Qt GUI and Android Application Package (APK) generation.
Unlike #32262, which focused on restoring the base cross-compilation, this PR provides a complete path to a functional Android application. It achieves this by updating the depends system to handle Android-specific requirements (shared Qt libraries, JNI support), integrating androiddeployqt into the CMake build system, and providing a standard Android entry point.
Alternatives
This PR is offered as an alternative to #32262. It incorporates and builds upon the depends fixes introduced there while adding the necessary components for a full GUI application and automated APK packaging.
Key Changes (mostly from #32262)
- build: Restored and updated Android cross-compilation support in the
dependssystem. This includes handling Android ABIs and mapping them to Bitcoin Core’sHOSTtriples. - build: Added APK generation support via a new
apk_packageCMake target. This target automates the generation ofdeploy.jsonand the execution ofandroiddeployqtto produce ready-to-install.apkfiles. - qt: Added Android-specific GUI configurations, including a Java entry point (
BitcoinQtActivity.java), high-resolution icons, and a manifest template. - doc: Added
doc/build-android.mdwith detailed instructions for setting up the Android SDK/NDK and building the GUI. - util: Added a deduction guide for
util::Overloadedto ensure compatibility with modern Android C++ toolchains. - depends: Applied several patches to Qt to fix JNI static linking issues and duplicate symbols encountered during Android builds.
Testing
The changes have been tested on Ubuntu 22.04 targeting x86_64-linux-android (API level 34) with NDK r26b and Qt 6.7.3. The resulting APK has been verified to install and run correctly on an Android emulator (see screenshot at the bottom).
Also it has been tested on a real devices with Android 13 (API level 33) for both abis arm64-v8a (aarch64) and armv7a.
Build Example:
0# Set environment
1export ANDROID_SDK_ROOT=/path/to/Android/Sdk
2export ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/26.1.10909125
3
4# Build dependencies
5gmake -C depends HOST=x86_64-linux-android ANDROID_SDK=$ANDROID_SDK_ROOT ANDROID_NDK=$ANDROID_NDK_ROOT ANDROID_API_LEVEL=34 NO_IPC=1 -j$(nproc)
6
7# Configure and build APK
8cmake -G Ninja -B build --toolchain depends/x86_64-linux-android/toolchain.cmake \
9 -DBUILD_GUI=ON -DANDROID_API_LEVEL=34 -j$(nproc)
10cmake --build build --target apk_package -j$(nproc)
Note for Reviewers
- Android does not support the system-wide IPC mechanisms used by Bitcoin Core’s multiprocess support, so
NO_IPC=1is currently required. - CI integration for the Android build is not included in this PR and will be addressed in a follow-up task if deemed necessary.