# 安装环境
pnpm install
# 热重载开发测试
pnpm tauri:dev
# 编译
pnpm tauri:build需要 Android Studio(含 NDK)和 rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android。
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
cp .env.template .env编辑 .env,至少设置:
ANDROID_HOME=
JAVA_HOME=如果 cargo/rustup 没有在全局 PATH 中,继续设置:
CARGO_HOME=如果机器上有多个 NDK,建议显式设置其一:
ANDROID_NDK_HOME=
# or
ANDROID_NDK_VERSION=30.0.14904198The Android script writes ANDROID_NDK_VERSION into
src-tauri/gen/android/app/build.gradle.kts as Gradle ndkVersion, so Gradle
and the MNN/Cargo cross-compile steps use the same NDK version.
MNN 默认构建 arm64-v8a,对应 Tauri target aarch64:
MNN_ANDROID_ABI=arm64-v8a
TAURI_ANDROID_TARGET=aarch64The Android MNN build is packaged as split runtime libraries by default. The build script requires at least these libraries before packaging:
MNN_ANDROID_RUNTIME_LIBS=libMNN.so,libMNN_Express.so,libllm.so,libMNNOpenCV.so,libMNNAudio.soAndroid MNN runtime libraries are stored under
src-tauri/native/prebuilt/android-${MNN_ANDROID_ABI}. Android builds prefer
that prebuilt directory and only rebuild MNN when the required libraries are
missing or FORCE_MNN=1 is set.
如需代理或 Gradle 镜像,也在 .env 中配置:
http_proxy=http://127.0.0.1:7890
https_proxy=http://127.0.0.1:7890
ANDROID_GRADLE_MIRRORS=https://maven.aliyun.com/repository/google,https://maven.aliyun.com/repository/central,https://maven.aliyun.com/repository/public,https://maven.aliyun.com/repository/gradle-pluginWindows 上如果 Cargo registry 和项目目录不在同一个盘,建议保留模板里的 Kotlin 设置,避免 Gradle 增量编译跨盘路径异常:
KOTLIN_INCREMENTAL=false
KOTLIN_COMPILER_EXECUTION_STRATEGY=in-process初始化/同步 Android 工程:
pnpm android:init只编译 MNN Android 动态库:
pnpm android:mnn:buildStore an existing Android MNN build into the prebuilt directory:
pnpm android:mnn:sync-prebuilt启动 Android dev 模式:
pnpm android:dev如果需要指定设备或 dev server host,在 .env 里设置:
TAURI_ANDROID_DEV_ARGS=3ac3e142 --host 192.168.1.10App 不内置下载模型。手动下载以下 ModelScope 模型后,将模型目录放到 AppData 的 models/<模型名> 下,或在「设置 -> 本地模型」里填写绝对路径:
Qwen3-VL-Embedding-2B-INT4-MNN
Qwen3-VL-2B-Instruct-MNN
Qwen3-ASR-0.6B-INT8-MNN
RAG vector search uses MobileLMStore as the vector database backend on Android.
Its SQLiteVDB sources are compiled into the native Rust/MNN bridge; no extra
runtime .so or script environment variable is required. The vector database is
created under the app data directory when knowledge entries are indexed.
Android debug 包可用 run-as 推入默认目录,例如:
adb shell run-as com.beyrion.sparcho mkdir -p files/models
adb push .\Qwen3-ASR-0.6B-INT8-MNN /data/local/tmp/Qwen3-ASR-0.6B-INT8-MNN
adb shell run-as com.beyrion.sparcho cp -r /data/local/tmp/Qwen3-ASR-0.6B-INT8-MNN files/models/构建 debug APK:
pnpm android:build:debug构建并安装到连接的设备:
pnpm android:install:debug强制重新编译 MNN:
FORCE_MNN=1 pnpm android:build:debugWindows PowerShell:
$env:FORCE_MNN="1"
pnpm android:build:debugAPK 输出在:
src-tauri/gen/android/app/build/outputs/apk/