android-architect
Architect-level Android guidance — Compose versus View system boundaries, lifecycle and configuration changes, state holders and unidirectional data flow, coroutine and work scheduling discipline, and the process-death and permission realities of the platform. Use for Android apps.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- android-architect
- license
- MIT
- metadata
- { "crusor-path": "mobile-architect/platforms-architect/android-architect", "crusor-domain": "mobile-architect", "crusor-origin": "original", "crusor-sources": "developer.android.com/guide; developer.android.com/jetpack/compose; developer.android.com/topic/architecture", "crusor-triggers": "android, kotlin, jetpack compose, viewmodel, gradle android, android app, coroutines", "crusor-verified-on": "2026-10-30" }
- description
- Architect-level Android guidance — Compose versus View system boundaries, lifecycle and configuration changes, state holders and unidirectional data flow, coroutine and work scheduling discipline, and the process-death and permission realities of the platform. Use for Android apps.
- compatibility
- Android 8+/API 26+; Kotlin; Jetpack Compose
03 SKILL.md 正文
Android Architect
Android gives you a process that can die at any time and a very wide device range. Architecture is about surviving both.
When to use
- Building or reviewing an Android app.
- Choosing Compose vs the View system, or migrating.
- Lifecycle, background work or state loss problems.
When NOT to use
- Cross-platform apps where the shared layer dominates.
Decision 1 — Compose vs Views
| Need | Choose |
|---|---|
| new UI, most screens | Jetpack Compose |
| legacy screens, complex custom views | View system, migrated incrementally |
| interop | ComposeView / AndroidView at the seam |
- Migrate screen by screen; a half-migrated app is expected, an unplanned one is not.
- Compose state hoisting: UI is a function of state; state lives in a holder, not in composables.
- No business logic in composables — they must be previewable and testable.
Decision 2 — Layering
ui/ (compose screens, viewmodels)
domain/ (use-cases, entities — no Android imports)
data/ (repositories, Room, Retrofit)
framework (DI modules, platform adapters)
- ViewModel holds UI state and survives configuration change — not process death.
- One-shot effects (navigation, snackbar) are events, not state that replays.
- DI (Hilt/Koin) wires the graph; screens never construct dependencies.
Decision 3 — Lifecycle and process death
- Configuration changes recreate activities; state must survive or be restored.
SavedStateHandle/SavedStateRegistryfor anything the user typed.- Background work: WorkManager with constraints and backoff — never a
Threador an alarm. - Doze and app-standby will defer your timers; design for late, not exact.
Decision 4 — Concurrency
- Coroutines with structured scopes:
viewModelScope,lifecycleScope; cancellation is automatic when the owner dies. - Dispatchers explicit:
IOfor disk/network,Defaultfor CPU,Mainonly for UI. - Flows for streams;
StateFlowfor UI state; one source of truth per screen. - No blocking calls on the main thread; StrictMode on in debug.
Decision 5 — Platform realities
- Permissions: request in context, handle permanent denial with a path to settings.
- Storage scoped storage rules; no writes outside app directories without SAF.
- Back navigation and predictive back gestures handled by the nav graph.
- Device fragmentation: test on API floor, a mid-tier device and a foldable profile.
Failure modes at scale
- God ViewModels with 40 fields and mixed responsibilities.
- State living in composables, lost on rotation.
- WorkManager chains that run forever because they are never cancelled.
- Two sources of truth (Room + in-memory cache) drifting apart.
- Blocking the main thread with JSON parsing on large payloads.
Verification receipts
- Rotation test on every stateful screen.
- Process-death restore test (developer option "don't keep activities").
- StrictMode clean in debug; no main-thread disk/network.
- Offline journey test with WorkManager retry.
- Baseline profile / startup time and jank trace on a mid-tier device.
04 同仓库更多 Skills
interaction-patterns-architect
Architect-level interaction design in code — choosing established patterns over invented ones, feedback and latency behaviour, destructive-action safeguards, navigation and overlay conventions, and the state model behind every interactive surface. Use when a screen has to behave, not just look.
design-system-ops-architect
Architect-level operation of a design system in code — token pipelines and versioning, component API and variant policy, the catalogue as the contract, adoption metrics, and the governance that stops a system from forking into three. Use when a component library must survive several teams.
design-handoff-architect
Architect-level design handoff — what must be specified before implementation starts, tokens over raw values, responsive and content-limit contracts, state matrices, and the review loop that catches drift between design and code. Use when a design is about to become code.
content-microcopy-architect
Architect-level UI content — where strings live, voice and terminology consistency, error and empty-state copy as part of the interface, translation-ready authoring, and the content model a product needs before it multiplies screens. Use when the words in the interface matter as much as the pixels.
ui-ux-implementation-architect
Architect-level direction for turning a design into working UI — the handoff contract, component ownership versus screen-level layout, interaction and state conventions, design QA gates, and the review habits that keep an implementation faithful without frozen pixels. Use before any specific UI implementation skill.
test-strategy-architect
Architect-level test strategy — allocating assertions across unit, integration, contract and end-to-end layers, designing for testability through dependency boundaries, fixture and data strategy, and the flake and coverage policies that keep a suite trustworthy. Use when defining how a codebase is tested.