Skip to content

ci: add setup_android_env.sh with ARM64 NDK fixes + bundled prebuilt tools - #920

Closed
Davinci198 wants to merge 1 commit into
AAswordman:mainfrom
Davinci198:ci/setup-env-ndk-arm64
Closed

ci: add setup_android_env.sh with ARM64 NDK fixes + bundled prebuilt tools#920
Davinci198 wants to merge 1 commit into
AAswordman:mainfrom
Davinci198:ci/setup-env-ndk-arm64

Conversation

@Davinci198

Copy link
Copy Markdown

Summary / 概述 / Rezumat

This PR adds a one-shot Android build environment bootstrap script plus two prebuilt tools, all required to build the app on ARM64 (arm64-v8a) hosts (Termux/proot, ARM servers).

本 PR 添加了一个一键式 Android 构建环境引导脚本,以及两个预编译工具,用于在 ARM64(arm64-v8a)主机(Termux/proot、ARM 服务器)上构建应用。

Acest PR adaugă un script complet de configurare a mediului de build Android plus două tool-uri precompilate, necesare pentru a compila aplicația pe gazde ARM64 (arm64-v8a) (Termux/proot, servere ARM).


What it includes / 包含内容 / Ce include

1. setup_android_env.sh (858 lines / 行 / linii)

  • Mirror selection / 镜像选择 / selecție mirror: fastest-mirror probing with download-speed measurement + ping fallback for Android command-line tools and Gradle (supports Google / Tsinghua / BFSU / Aliyun / Tencent mirrors).

    • 通过测速 + ping 回退自动选择最快的镜像(Google / 清华 / 北外 / 阿里云 / 腾讯)。
    • Selectare automată a celui mai rapid mirror (Google / Tsinghua / BFSU / Aliyun / Tencent).
  • ensure_ndk_arm64_toolchain: replaces the x86-64 NDK linkers with native ARM64 LLVM 18 (ld/ld.lld/lld + llvm-ar/llvm-ranlib/llvm-strip), fixing link crashes and --record-libdeps incompatibility on ARM64.

    • 将 x86-64 NDK 链接器替换为原生 ARM64 LLVM 18,修复 ARM64 上的链接崩溃与 --record-libdeps 不兼容问题。
    • Înlocuiește linker-ele x86-64 din NDK cu LLVM 18 nativ ARM64, rezolvând crash-uri de link și incompatibilitatea --record-libdeps.
  • patch_ndk_sysroot_libs: creates stub libgcc.a / libunwind.a / libatomic.a in the NDK sysroot, fixing bad_array_new_length and aligned operator new link errors under NDK 27.

    • 在 NDK sysroot 中创建 libgcc.a/libunwind.a/libatomic.a 桩文件,修复 NDK 27 下的 bad_array_new_length 与对齐 operator new 链接错误。
    • Creează stub-uri libgcc.a/libunwind.a/libatomic.a în sysroot-ul NDK, rezolvând erorile bad_array_new_length și operator new aliniat.
  • fix_aidl_arm64: wraps the x86-64 aidl binary with a qemu shim and generates IAccessibilityProvider / IAccessibilityEventCallback (AGP does not generate them).

    • 为 x86-64 aidl 添加 qemu 包装器,并生成 AGP 不会自动生成的 IAccessibilityProvider/IAccessibilityEventCallback
    • Împachetează binarul x86-64 aidl cu un shim qemu și generează interfețele IAccessibilityProvider/IAccessibilityEventCallback (AGP nu le generează).
  • ensure_native_libs: offline copy of dragonbones-release.aar v1.1.0 from tools/dragonbones (SHA256-verified) + optional ffmpeg-kit-local.aar check.

    • tools/dragonbones 离线复制 dragonbones-release.aar v1.1.0(SHA256 校验)+ 可选 ffmpeg-kit-local.aar 检查。
    • Copie offline a dragonbones-release.aar v1.1.0 din tools/dragonbones (SHA256 verificat) + verificare opțională pentru ffmpeg-kit-local.aar.
  • replace_aapt2: swaps the SDK/Gradle-cache aapt2 with the bundled ARM64 binary so resource processing works on ARM64.

    • 用随附的 ARM64 二进制替换 SDK/Gradle 缓存中的 aapt2,确保资源处理在 ARM64 上正常工作。
    • Înlocuiește aapt2-ul din SDK/cache-ul Gradle cu binarul ARM64 inclus, pentru ca procesarea resurselor să funcționeze pe ARM64.
  • proot/Termux compatibility / proot/Termux 兼容 / compatibilitate proot/Termux: disables the AAPT2 daemon, restores a safe gradle.properties, persists env vars in ~/.bashrc, and writes local.properties.

2. tools/aapt2/aapt2-arm64-v8a — native ARM64 AAPT2 (ELF aarch64, statically linked, sha256 e5b5ff7f…) bundled in the repo; no Gradle cache patching needed.

  • 原生 ARM64 AAPT2(ELF aarch64),直接入库,无需修补 Gradle 缓存。
  • AAPT2 nativ ARM64 (ELF aarch64) inclus în repo; nu mai e nevoie de patch pe cache-ul Gradle.

3. tools/dragonbones/dragonbones-release.aar — prebuilt DragonBones v1.1.0 (sha256 639238ed…) bundled for fully offline builds.

  • 预编译 DragonBones v1.1.0,支持完全离线构建。
  • DragonBones v1.1.0 precompilat, pentru build-uri complet offline.

Validation / 验证 / Validare

  • bash -n setup_android_env.sh — syntax OK (语法通过 / sintaxă OK)
  • git diff --check — no whitespace errors (无空白错误 / fără erori de whitespace)
  • ci/script/check_repo_hygiene.py --base main --candidate HEADerrors=0 warnings=0
  • ci/script/check_markdown_links.pyerrors=0 warnings=0
  • Prebuilt binary checksums verified against the values embedded in the script.
    • 预编译二进制校验和与脚本内嵌值一致。
    • Checksum-urile binarelor precompilate corespund cu valorile din script.

Testing / 测试 / Testare

The same change set has been merged and validated in Davinci198/fix-operit (PR #12, checks SUCCESS): full ARM64 native build pipeline (mmd + llama passed). This PR ports those validated fixes to this repository.

相同变更已在 Davinci198/fix-operit 中合并并验证(PR #12,检查全部通过):完整的 ARM64 原生构建流水线(mmd + llama 均通过)。本 PR 将这些已验证的修复移植到本仓库。

Aceleași modificări au fost deja merge-uite și validate în Davinci198/fix-operit (PR #12, checks SUCCESS): pipeline-ul complet de build nativ ARM64 (mmd + llama au trecut). Acest PR portează acele fix-uri validate către acest repo.


Closes (if applicable / 若适用 / dacă e cazul): ARM64 build support (Termux/proot / ARM servers).

…tools

- setup_android_env.sh: full Android build environment bootstrap
  - mirror selection (speed + ping fallback) for cmdline-tools/Gradle
  - ensure_ndk_arm64_toolchain: replace x86-64 NDK linkers with native
    LLVM 18 (ld/ld.lld/lld + llvm-ar/ranlib/strip) for ARM64 hosts
  - patch_ndk_sysroot_libs: stub libgcc/libunwind/libatomic to fix
    bad_array_new_length and aligned operator new link errors (NDK 27)
  - fix_aidl_arm64: AIDL wrapper (qemu) for x86-64 binary + generate
    IAccessibilityProvider/IAccessibilityEventCallback (AGP misses them)
  - ensure_native_libs: offline dragonbones AAR (SHA256 verified) and
    ffmpeg-kit-local.aar check
  - replace_aapt2: swap SDK/Gradle-cache aapt2 with bundled ARM64 binary
  - proot/Termux compatibility: AAPT2 daemon disabled, gradle.properties
    restored to a safe state, local.properties/~/bashrc persistence
- tools/aapt2/aapt2-arm64-v8a: ARM64 native AAPT2 (ELF aarch64, sha256
  e5b5ff7f...) bundled in repo to avoid Gradle-cache patching needs
- tools/dragonbones/dragonbones-release.aar: prebuilt v1.1.0 (sha256
  639238ed...) bundled for offline builds

@AAswordman AAswordman left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Request changes.\n\nP1: Running setup_android_env.sh overwrites tracked project files (gradle/wrapper/gradle-wrapper.properties, gradle.properties, and gradlew.bat) and appends persistent settings to ~/.bashrc. It discards existing Gradle settings such as the repository's 8 GiB JVM allocation and changes the wrapper to a machine-local file URL. A setup helper must not silently rewrite repository/user configuration; constrain writes to explicitly requested, local-only configuration.\n\nP1: The two added opaque binaries total about 7.2 MB. The script only verifies their self-declared SHA-256 values, which proves neither source nor provenance. Provide official upstream/reproducible-build provenance, version/license metadata, and a reviewable acquisition path before adding them to the repository.\n\nP1: Several prerequisite failures are logged and then ignored, yet the script still prints that setup completed. In particular, failed Gradle/AAPT2 warm-ups and failed AIDL generation do not prevent success. This can report a usable environment when required build tools are unavailable.\n\nThe branch has no Candidate checks and is based behind current main.

@Davinci198 Davinci198 closed this Aug 13, 2026
@Davinci198

Copy link
Copy Markdown
Author

Bye

@Davinci198
Davinci198 deleted the ci/setup-env-ndk-arm64 branch August 13, 2026 11:36
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.

2 participants