从源码构建
本页介绍如何从源码构建 Local Dream。构建结果与 GitHub Releases 发布的 APK 完全一致。
TIP
推荐在 Linux 或 WSL 上构建。macOS 和 Windows 也可以构建,但验证较少。
前置要求
需要以下工具:
Rust — 通过 rustup 安装,然后固定版本为
1.84.0:bashrustup default 1.84.0 # 必须使用 1.84.0;更新的版本会导致构建失败 rustup target add aarch64-linux-androidNinja — 构建系统
CMake — 构建配置
Android Studio — 用于最终的 APK 打包
1. 克隆仓库
bash
git clone --recursive https://github.com/xororz/local-dream.git--recursive 参数是必需的——子模块包含构建依赖。
2. 准备 SDK
- QNN SDK 2.39 — 下载 v2.39.0.250926.zip 并解压。
- Android NDK — 从 Android NDK 下载页获取并解压。
- 在以下两个文件中更新 SDK 路径:
app/src/main/cpp/CMakeLists.txt中的QNN_SDK_ROOTapp/src/main/cpp/CMakePresets.json中的ANDROID_NDK_ROOT
3. 构建原生库
Linux
bash
cd app/src/main/cpp/
bash ./build.shWindows
powershell
# 如需安装构建工具:
# winget install Kitware.CMake
# winget install Ninja-build.Ninja
# winget install Rustlang.Rustup
cd app\src\main\cpp\
# 转换补丁文件的换行符(如需安装 dos2unix:
# winget install -e --id waterlan.dos2unix)
dos2unix SampleApp.patch
.\build.batmacOS
bash
# 使用 Homebrew 安装构建工具:
# brew install cmake rust ninja
# 修复 macOS 上较新版本 CMake 的策略兼容性问题
sed -i '' '2s/$/ -DCMAKE_POLICY_VERSION_MINIMUM=3.5/' build.sh
bash ./build.sh4. 构建 APK
在 Android Studio 中打开项目,然后:
Build → Generate App Bundles or APKs → Generate APKs
APK 输出到 app/build/outputs/apk/。