Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ These structural facts shape every module. Day-to-day build *commands* live in `
- **ABI product flavors.** Every Android module *except* `:plugin-api` gets two flavors on the `abi` dimension — `v7` (`armeabi-v7a`) and `v8` (`arm64-v8a`) — defined centrally. There is no flavorless variant; tasks are `assembleV8Debug`, `assembleV7Release`, etc.
- **SDK levels** (`build-logic/.../build/config/BuildConfig.kt`): `COMPILE_SDK=36`, `MIN_SDK=28`, `TARGET_SDK=28`. **`TARGET_SDK` is deliberately pinned at 28:** higher targets enforce W^X (write-xor-execute), which blocks executing code from app-writable files. That is fatal for an on-device IDE that compiles and runs code (Gradle, `javac`, Termux binaries), so it is a hard requirement, not tech debt. `MIN_SDK_FOR_APPS_BUILT_WITH_COGO=16` is the floor for the apps a *user* builds with CoGo — distinct from CoGo's own `MIN_SDK`.
- **Native asset bundling.** The on-device LLM (`llama-impl`) ships as a per-flavor native AAR, wired through the root `build.gradle.kts` (`bundleLlamaV8Assets` / `assembleV8Assets`, …); prebuilt per-flavor assets live under `assets/release/v7/` and `assets/release/v8/`.
- **Native lib compression** (ADFA-2306). Bundled-assets variants (release/instrumentation) set `jniLibs.useLegacyPackaging = true` per-variant in `AndroidModuleConf.kt`, so their `lib/<abi>/*.so` ship deflate-compressed and the installer extracts them at install time — ~5.9 MB smaller per APK (`libtree-sitter-kotlin.so` alone is 4.18 MB → 339 kB). Debug keeps modern packaging (uncompressed, mmap'd from the APK) via the `false` default in `app/build.gradle.kts`. Coupled invariant: the `recompressApk` post-step's no-compress list must keep `"so"` for debug (stored libs are required for loading from the APK) but exclude it for release (`noCompressRelease`), or it silently re-stores the libs and undoes the saving.
- **Native lib compression** (ADFA-2306, ADFA-4729). The app manifest hard-codes `android:extractNativeLibs="true"` (required: the installer must materialize libs in `nativeLibraryDir`, e.g. `libshizuku.so` is an executable the adb shell runs from there). That attribute overrides the `jniLibs.useLegacyPackaging` DSL, so AGP packages `lib/<abi>/*.so` deflate-compressed in **every** APK — ~5.9 MB smaller (`libtree-sitter-kotlin.so` alone is 4.18 MB → 339 kB). The trap is the `recompressApk` post-step (release always, debug in CI only): its no-compress lists in `app/build.gradle.kts` must NOT contain `"so"`, or it silently re-stores the libs and undoes the saving — which is what ADFA-2306 fixed for release and ADFA-4729 for CI debug. Locally built debug APKs (including the e2e farm's) never run that step and were always fine.
- **`app` package layout is by concern, not feature:** `activities`, `fragments`, `services`, `di`, `agent`, `viewmodel(s)`, `repositories`, `roomData`, `localWebServer`, `preferences`, `ui`, `utils`, ….

## Technology Stack
Expand Down
14 changes: 8 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,14 @@ val noCompress =
// Debug APKs DEFLATE jar assets (tooling-api-all.jar, cogo-plugin.jar) for
// ~75% size reduction (ADFA-4188). Release keeps jars STORED because
// tooling-api-all.jar ships as a brotli-encoded .jar.br.
val noCompressDebug = noCompress - "jar"

// Release APKs DEFLATE native libs for ~5.9 MB size reduction (ADFA-2306): release uses
// legacy jniLibs packaging (extractNativeLibs=true, set in AndroidModuleConf.kt), so the
// installer extracts them at install time and they need not be STORED for mmap. Debug
// keeps "so" STORED because it loads libs directly from the APK.
//
// "so" stays DEFLATED in both lists (ADFA-2306 release, ADFA-4729 CI debug): the app
// manifest hard-codes extractNativeLibs="true", so the installer extracts libs to
// nativeLibraryDir at install time and AGP already packages them deflate-compressed
// (~5.9 MB smaller per APK). Re-storing them here would silently undo that, which is
// exactly what happened to CI debug APKs before ADFA-4729. Local debug builds never
// run this task and get AGP's deflated packaging as-is.
val noCompressDebug = noCompress - "jar" - "so"
val noCompressRelease = noCompress - "so"

afterEvaluate {
Expand Down
Loading