Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。
perf(build): cut the APK from 39 MB to ~8 MB with an ABI split and R8
booboosuibdd81d508ddc
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 15c7f47..09fae2b 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -38,5 +38,29 @@ jobs:- uses: actions/upload-artifact@v4with:name: app-debug- path: app/build/outputs/apk/debug/app-debug.apk+ # One APK per ABI, so the glob replaces what used to be a single+ # `app-debug.apk`: ML Kit's barhopper .so is ~4 MB and the fat APK+ # carried four copies of it. See the `splits` block in app/build.gradle.+ path: app/build/outputs/apk/debug/*.apkif-no-files-found: error++ # assembleRelease is its own job rather than a step above, because it is a+ # *gate* and not a deliverable: the APK has no signingConfig and cannot be+ # installed. What it catches is what went unnoticed until now — R8 and+ # `lintVitalRelease` only run on release, so a missing keep rule, or a+ # resource the lint check cannot parse, is invisible until someone tries to+ # ship. That is exactly how a failing `assembleRelease` sat in this repo.+ # Runs in parallel, so it costs a PR no wall-clock time.+ release-gate:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4++ - uses: actions/setup-java@v4+ with:+ distribution: temurin+ java-version: '17'++ - uses: gradle/actions/setup-gradle@v3++ - run: ./gradlew --no-daemon :app:assembleReleasediff --git a/CHANGELOG.md b/CHANGELOG.mdindex e0e8be3..0274a3d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -83,6 +83,23 @@ build time would close this hole; it is not implemented yet.)### Changed+- **The APK went from ~39 MB to ~8 MB.** Two causes, both structural rather than a matter of+ trimming assets. First, every build produced one *fat* APK for all four ABIs, and ML Kit's+ `libbarhopper_v3.so` is ~4 MB, so it was paid for four times over. Second, the debug variant ships+ un-shrunk dex (16.7 MB of it, against 3.2 MB after R8), and `minifyEnabled` was off on release too.+ Fixed with an ABI split, `minifyEnabled` + `shrinkResources` on release, and deflated native libs.+ **The output paths changed**: there is no `app-debug.apk` any more, only `app-<abi>-debug.apk` and+ `app-<abi>-release-unsigned.apk`. `assembleRelease` also runs in CI now, as a job parallel to the+ debug one, because R8 and `lintVitalRelease` only run on release — and that is exactly how a+ release build that failed on every invocation sat in the repository unnoticed.+- **`assembleRelease` builds again.** It had been failing in `lintVitalRelease` on+ `res/xml/backup_rules.xml` and `res/xml/data_extraction_rules.xml`, both of which exclude+ `domain="device_root"`. That is a real domain — the framework has carried+ `DEVICE_ROOT_TREE_TOKEN` since device-protected storage landed, and the Auto Backup reference+ defines `device_root` as "like root but for the device-protected storage". AGP 8.3's+ `FullBackupContent` check validates against a five-value list that predates it, so the error was a+ false positive. Both lines now carry a scoped `tools:ignore`; the check still covers everything+ else in those files, including a genuine typo in a domain.- **`SECURITY.md` no longer claims a safeguard the software does not have.** Itsprompt-injection section stated that destructive or irreversible actions are*"gated behind `ask_user` / `confirm` flows"*. That is not true, and it was thediff --git a/CLAUDE.md b/CLAUDE.mdindex b2d95fe..3195376 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -16,13 +16,22 @@ Two orientation facts that are easy to get wrong:## Build and run```bash-./gradlew assembleDebug # APK → app/build/outputs/apk/debug/app-debug.apk+./gradlew assembleDebug # APKs → app/build/outputs/apk/debug/app-<abi>-debug.apk./gradlew installDebug # build + install to the attached device+./gradlew assembleRelease # minified APKs → app/build/outputs/apk/release/app-<abi>-release-unsigned.apk./gradlew test # host-side JUnit (only template tests exist)./gradlew connectedAndroidTest # instrumented tests (needs a device; only a template test exists)adb logcat -s Body:* BodyWs:* BodyWsClient:* Asr:* Tts:* # the log tags this app uses```+**The APK path is per-ABI and there is no `app-debug.apk` any more.** An ABI split plus+`minifyEnabled`/`shrinkResources` on release (see the comments in `app/build.gradle`) took the arm64+arm from 39 MB to ~8 MB — the fat APK was carrying four copies of ML Kit's ~4 MB `libbarhopper_v3.so`,+and the debug variant was carrying 13 MB of un-shrunk dex. Hand someone+`app-arm64-v8a-release-unsigned.apk`, not the debug build, once it is signed; `assembleRelease` is+also a CI gate now, because R8 and `lintVitalRelease` only run there and a release build that nobody+runs is how a broken `assembleRelease` sat unnoticed.+There is **no real test suite** — `ExampleUnitTest` / `ExampleInstrumentedTest` are unmodified templates. Verification is manual: install, watch logcat, drive the ball. There is no lint/format task configured beyond AGP defaults.Toolchain notes that bite:diff --git a/README.md b/README.mdindex e2c69fa..5647395 100644--- a/README.md+++ b/README.md@@ -256,7 +256,7 @@ To build it yourself instead:> nothing it does is meaningful there```bash-./gradlew clean :app:assembleDebug # → app/build/outputs/apk/debug/app-debug.apk+./gradlew clean :app:assembleDebug # → app/build/outputs/apk/debug/app-<abi>-debug.apk./gradlew installDebug # build + install to an attached device# then, on the device, in this order:@@ -292,9 +292,13 @@ You do not have to remember this: the first run is a stepped setup that walks yoafterwards the **✓** button in the ball's control bar opens the self-check list, which says which ofthe two is missing and offers the button that fixes it.-**Use `assembleDebug`, not `assembleRelease`.** The release build type has no `signingConfig` and-there is no keystore in the repo, so `assembleRelease` emits `app-release-unsigned.apk`, which will-not install. The debug build is signed with the standard Android debug certificate.+**To hand someone an APK, sign a release build — not the debug one.** The release build type is the+minified one (`minifyEnabled` + `shrinkResources`), and that is most of what makes the APK small: the+debug variant ships un-shrunk dex. It has no `signingConfig` and there is no keystore in the repo, so+`assembleRelease` emits `app-<abi>-release-unsigned.apk`, which will not install until you sign it.+The debug build is signed with the standard Android debug certificate and installs as-is. Either way+the APK is **per-ABI** (`splits` in `app/build.gradle`), so pick the one that matches the device —+`arm64-v8a` for anything bought in the last several years.**If the build does not work, the answer is almost always the JDK.** Full from-scratch setup — theJDK traps, the Android SDK two different ways (including a command-line-only path for CI), and a table@@ -633,7 +637,7 @@ Gradle reads either../gradlew installDebug # device attached over USB, or already on wireless adb# or build the APK and install it yourself./gradlew assembleDebug-adb install -r app/build/outputs/apk/debug/app-debug.apk+adb install -r app/build/outputs/apk/debug/app-arm64-v8a-debug.apk```### Provisioning orderdiff --git a/README.zh-CN.md b/README.zh-CN.mdindex c690fc7..52076f7 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -228,7 +228,7 @@ Android。跟它要一个 Andee,它会交给你一个**已经配好令牌**的> - **真机。** 这个应用本身就是那个无障碍服务;模拟器能跑,但它几乎什么都干不了```bash-./gradlew clean :app:assembleDebug # 产物 app/build/outputs/apk/debug/app-debug.apk+./gradlew clean :app:assembleDebug # 产物 app/build/outputs/apk/debug/app-<abi>-debug.apk./gradlew installDebug # 构建并安装到已连接的设备# 然后在设备上,按这个顺序:@@ -258,9 +258,12 @@ OpenAI 兼容端点(`llm_api_key`,默认 `https://api.deepseek.com`)。**这些不用记:第一次启动会有一个分步引导,带你把这两样填好;之后球的控制条上的 **✓** 会打开自检清单,直接告诉你缺哪一个,并给出去处理的按钮。-**打包装 `assembleDebug`,别用 `assembleRelease`。** release 没有 `signingConfig`,仓库里也没有-keystore,`assembleRelease` 产出的是 `app-release-unsigned.apk`,**装不上**。debug 包用 Android-默认调试证书签名。+**要拿 APK 给别人装,签一个 release 包,别发 debug 包。** release 才是压过的那版+(`minifyEnabled` + `shrinkResources`),体积小主要就小在这里——debug 包带的是没压过的 dex。+它没有 `signingConfig`,仓库里也没有 keystore,所以 `assembleRelease` 产出的是+`app-<abi>-release-unsigned.apk`,**不签名装不上**。debug 包用 Android 默认调试证书签名,+可以直接装。两种包都是**按 ABI 拆开的**(见 `app/build.gradle` 里的 `splits`),拿和设备对得上+的那个——近几年买的机器基本都是 `arm64-v8a`。#### 遇到问题@@ -485,7 +488,7 @@ Linux 通常是 `/home/<user>/Android/Sdk`,Windows 是./gradlew installDebug # 设备已插 USB 或已连 wifi adb# 或者产出 APK 后自己 adb install./gradlew assembleDebug-adb install -r app/build/outputs/apk/debug/app-debug.apk+adb install -r app/build/outputs/apk/debug/app-arm64-v8a-debug.apk```## 权限总览diff --git a/app/build.gradle b/app/build.gradleindex d328f57..ecd36a0 100644--- a/app/build.gradle+++ b/app/build.gradle@@ -54,10 +54,41 @@ android {buildTypes {release {- minifyEnabled false+ minifyEnabled true+ shrinkResources trueproguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'}}+ // One APK per ABI instead of one fat APK carrying all four. ML Kit's+ // barhopper .so alone is ~4 MB per ABI, so the fat APK paid that four+ // times over. x86 (32-bit) is deliberately dropped: no emulator has needed+ // it for years. x86_64 stays so an emulator still installs something.+ //+ // `universalApk false` on purpose: a fat APK sitting next to the split ones+ // is a trap — it is the file someone grabs when they are in a hurry, and it+ // is four times the size. Anything the splits do not cover is a device this+ // app cannot be provisioned on anyway.+ splits {+ abi {+ enable true+ reset()+ include 'arm64-v8a', 'armeabi-v7a', 'x86_64'+ universalApk false+ }+ }+ // Native libs ship deflated rather than page-aligned-and-stored. AGP 8+ // defaults to stored (`extractNativeLibs="false"`), which is the better+ // trade for a store install — the libs are mapped straight out of the APK+ // with no second copy on disk. This app is side-loaded instead, where the+ // size of the file being handed over is the thing that matters, and+ // barhopper deflates 4.2 MB → 1.8 MB. The cost is ~4 MB of extra on-device+ // storage per install and a slightly slower install. Flip to false if that+ // trade ever stops being the right one.+ packaging {+ jniLibs {+ useLegacyPackaging = true+ }+ }compileOptions {sourceCompatibility JavaVersion.VERSION_1_8targetCompatibility JavaVersion.VERSION_1_8diff --git a/app/src/main/res/xml/backup_rules.xml b/app/src/main/res/xml/backup_rules.xmlindex f4fd044..52051e9 100644--- a/app/src/main/res/xml/backup_rules.xml+++ b/app/src/main/res/xml/backup_rules.xml@@ -6,9 +6,16 @@read the other one. It is dead while `android:allowBackup="false"` stands, andit is filled in anyway so that flipping that attribute does not quietly startuploading the vault.++ `device_root` is a real domain here too — the framework has carried+ DEVICE_ROOT_TREE_TOKEN since device-protected storage landed — but AGP 8.3's+ `FullBackupContent` lint check validates against a five-value list that+ predates it and reports an error. `lintVitalRelease` runs on every release+ build, so that false positive is what used to make `assembleRelease` fail.+ See data_extraction_rules.xml, which needs the same ignore.-->-<full-backup-content>+<full-backup-content xmlns:tools="http://schemas.android.com/tools"><exclude domain="root" path="." /><exclude domain="external" path="." />- <exclude domain="device_root" path="." />+ <exclude domain="device_root" path="." tools:ignore="FullBackupContent" /></full-backup-content>diff --git a/app/src/main/res/xml/data_extraction_rules.xml b/app/src/main/res/xml/data_extraction_rules.xmlindex f3a67e4..0f13af2 100644--- a/app/src/main/res/xml/data_extraction_rules.xml+++ b/app/src/main/res/xml/data_extraction_rules.xml@@ -17,16 +17,24 @@The vault would not survive a restore anyway — its key lives in the hardwareKeystore and does not travel — but an undecryptable blob arriving on a newdevice is pure downside, not a safeguard.++ `device_root` is a documented domain for these rules — "like root but for+ device-protected storage", per the Auto Backup reference. AGP 8.3's+ `FullBackupContent` lint check still validates against the older+ `full-backup-content` domain list, which predates `device_*`, and reports it+ as an error; because `lintVitalRelease` runs on every release build, that+ false positive is what used to make `assembleRelease` fail outright. The+ ignores below are scoped to those two lines and nothing else.-->-<data-extraction-rules>+<data-extraction-rules xmlns:tools="http://schemas.android.com/tools"><cloud-backup><exclude domain="root" path="." /><exclude domain="external" path="." />- <exclude domain="device_root" path="." />+ <exclude domain="device_root" path="." tools:ignore="FullBackupContent" /></cloud-backup><device-transfer><exclude domain="root" path="." /><exclude domain="external" path="." />- <exclude domain="device_root" path="." />+ <exclude domain="device_root" path="." tools:ignore="FullBackupContent" /></device-transfer></data-extraction-rules>