build: Alt restore cross-compilation for Android #34211

pull D33r-Gee wants to merge 5 commits into bitcoin:master from D33r-Gee:260601-android-deployqt-build changing 26 files +529 −28
  1. D33r-Gee commented at 4:48 pm on January 6, 2026: none

    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 depends system. This includes handling Android ABIs and mapping them to Bitcoin Core’s HOST triples.
    • build: Added APK generation support via a new apk_package CMake target. This target automates the generation of deploy.json and the execution of androiddeployqt to produce ready-to-install .apk files.
    • 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.md with detailed instructions for setting up the Android SDK/NDK and building the GUI.
    • util: Added a deduction guide for util::Overloaded to 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=1 is 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.

    Emulator Screenshot

  2. DrahtBot added the label Build system on Jan 6, 2026
  3. DrahtBot commented at 4:49 pm on January 6, 2026: contributor

    ♻️ Automatically closing for now based on heuristics. Please leave a comment, if this was erroneous. Generally, please focus on creating high-quality, original content that demonstrates a clear understanding of the project’s requirements and goals.

    📝 Moderators: If this is spam, please replace the title with ., so that the thread does not appear in search results.

  4. DrahtBot closed this on Jan 6, 2026

  5. DrahtBot commented at 4:49 pm on January 6, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34211.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  6. hebasto reopened this on Jan 6, 2026

  7. hebasto added the label Android on Jan 6, 2026
  8. in src/util/overloaded.h:17 in d97f5a9376 outdated
    13@@ -14,6 +14,7 @@ namespace util {
    14 //! Implementation comes from and example usage can be found at
    15 //! https://en.cppreference.com/w/cpp/utility/variant/visit#Example
    16 template<class... Ts> struct Overloaded : Ts... { using Ts::operator()...; };
    17+template<class... Ts> Overloaded(Ts...) -> Overloaded<Ts...>;
    


    maflcko commented at 5:00 pm on January 6, 2026:

    why is this changed? It would be good to explain in the commit message.

    If clang-16 is required, it could make sense to revert faed118fb30fbc303e9d4c70569abfee397f1759. If not, it could make sense to just use clang-17.


    D33r-Gee commented at 5:20 pm on January 6, 2026:
    taking a look now… will update soon

    D33r-Gee commented at 9:19 pm on January 6, 2026:
    Android NDK r26 uses Clang 17; this was tested with that toolchain and it fails to compile without the deduction guide. If there’s a more elegant solution, I’m happy to revise — feedback welcome.
  9. fanquake commented at 5:01 pm on January 6, 2026: member
    @hebasto why isn’t this AI? It contains nonsensical/unexplained changes, like reintroducing #33850 and removing support for Qt FreeBSD from depends, no real commit messages etc. Other nonsense like “Qt chain-load toolchain”.
  10. in depends/toolchain.cmake.in:85 in d97f5a9376
    93+
    94+    # Ensure CMake can locate Qt and our depends prefix first.
    95+    list(PREPEND CMAKE_PREFIX_PATH "${_QT_ANDROID_SDK}")
    96+    list(APPEND CMAKE_FIND_ROOT_PATH "${_QT_ANDROID_SDK}")
    97+
    98+    # Disable unwanted Qt ZSTD resource compression to save APK size.
    


    fanquake commented at 5:30 pm on January 6, 2026:
    Why does disabling compression reduce the size of the APK? (I can’t tell if QT_RESOURCE_FEATURE_ZSTD is a real option)

    D33r-Gee commented at 11:01 pm on January 6, 2026:
    Thanks for reviewing this… This was left over from my original tinkering with androiddeployqt when I thought it had to be an external toolchain. It has now been removed.
  11. D33r-Gee force-pushed on Jan 6, 2026
  12. D33r-Gee commented at 11:02 pm on January 6, 2026: none

    with e9ec301 it has been rebased over master and the comments from @maflcko and @fanquake have been addressed with the following:

    • Restored Qt FreeBSD support in depends.
    • Removed obsolete qtbase_avoid_native_float16.patch and the unused fix_android_duplicate_symbol.patch.
    • Removed the experimental external Qt integration from toolchain.cmake.in.
    • Expanded the explanation for the util::Overloaded deduction guide change to clarify its role in Android NDK builds.
    • Fixed typos in template_deploy.json and corrected various grammar issues in doc/build-android.md.
  13. util: Add deduction guide for util::Overloaded
    Add an explicit deduction guide for util::Overloaded to improve
    compatibility with Android NDK toolchains where template argument
    deduction for this helper can fail.
    fbe443d247
  14. build: Restore cross-compilation for Android
    Integrate Android NDK support into the depends build system.
    
    - Add Android OS detection to depends/Makefile.
    - Introduce conditional CMake command construction in depends/funcs.mk
      to support the Android NDK toolchain while preserving standard behavior
      for other platforms.
    - Update toolchain.cmake.in to include Android-specific configurations
      when targeting Android.
    - Add necessary patches and package configurations for libevent and Qt 6
      to support Android-specific requirements (e.g., JNI statics, thread fixes).
    737ad0a6d4
  15. qt: Add Android GUI support
    Introduce necessary files and configurations to enable building the
    Qt-based Bitcoin Core GUI for Android.
    
    - Add AndroidManifest.xml and application icons.
    - Implement BitcoinQtActivity.java to handle application lifecycle
      on Android.
    - Configure CMake to include Android-specific Qt translations and
      resources.
    6e822715b1
  16. build: Add Android APK packaging with androiddeployqt
    Add build system logic to automate the creation of Android Application
    Packages (APKs).
    
    - Implement a custom APK build target in src/qt/android/CMakeLists.txt.
    - Integrate the androiddeployqt tool into the CMake build process.
    - Provide template_deploy.json for configuring the deployment process.
    a2c707d841
  17. doc: Add Android build and packaging guide
    Add documentation for building and packaging the Bitcoin Core GUI for Android on Linux and macOS.
    
    - Android SDK/NDK dependencies and API levels.
    - Build commands using CMake and Ninja.
    - Packaging instructions for generating APKs.
    75dc338f27
  18. in depends/patches/qt/qtbase-moc-ignore-gcc-macro.patch:1 in e9ec301da4
    0@@ -0,0 +1,17 @@
    1+The moc executable loops through headers on CPLUS_INCLUDE_PATH and stumbles
    


    fanquake commented at 12:50 pm on January 8, 2026:
    This is still just making random changes (this patch was removed because the issue has been fixed in Qt).

    D33r-Gee commented at 5:52 pm on January 8, 2026:
    Thanks for pointing this out, this was left over from previous attempts at the Android build and since it was causing any problems for the apk build it slipped though the cracks. It has been removed.
  19. D33r-Gee force-pushed on Jan 8, 2026
  20. D33r-Gee commented at 5:49 pm on January 8, 2026: none

    with 75dc338 it has been rebased over master and @fanquake comment has been addressed:


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-01-09 09:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me