# Installation (https://crow.build/docs/installation)

Crow is structured as a modular set of Kotlin libraries powered by the **`crow-compiler`** K2 plugin, the zero-Gradle **`crow-build`** engine (`crow.jsonc` + `crow` CLI), and Gradle plugins (`crow.app` and `crow.routes`).

## Requirements [#requirements]

- **Kotlin**: `2.4.21` (K2 compiler)
- **JDK**: `17` toolchain (`21` for AGP runtime)
- **Android**: `minSdk = 26` (`compileSdk = 36`)
- **Gradle**: `9.9+` (when building with Gradle)

## Option A: Declarative `crow.jsonc` (Zero-Gradle) [#option-a-declarative-crowjsonc-zero-gradle]

Scaffold a new Android-native Crow app with the `crow` CLI:

```bash
crow new my-app --design-system lens --routes --inject
cd my-app
crow dev
```

Your project manifest lives in `crow.jsonc` with full JSON Schema validation and deterministic `crow.lock` dependency locking.

## Option B: Gradle Setup [#option-b-gradle-setup]

<Steps>
<Step>
### Apply Crow Gradle plugins [#apply-crow-gradle-plugins]

For a standalone Android app, apply `crow.app` (which generates your zero-AndroidX `Activity` and `Application` from `@CrowApp`) and optionally `crow.routes` for file-based routing.

```kotlin title="app/build.gradle.kts"
plugins {
    alias(libs.plugins.android.application)
    id("crow.app")
    id("crow.routes") // Optional: file-based routing
}
```
</Step>

<Step>
### Register the K2 compiler plugin [#register-the-k2-compiler-plugin]

Wire `crow-compiler` into Kotlin's compiler plugin classpath so `@Ui` functions, live props, `LocalGraph` lowering, modifier fusion, zero-key `saved()`, and `CR1001`/`CR1002`/`CR1003` checks run automatically:

```kotlin title="app/build.gradle.kts"
configurations
    .matching { it.name.startsWith("kotlinCompilerPluginClasspath") }
    .configureEach {
        dependencies.add(project.dependencies.project(":crow-compiler"))
    }
```
</Step>

<Step>
### Add dependencies [#add-dependencies]

Pick only the modules you need. Every core library stays strictly independent of design systems (`crow-material3` and `crow-lens` are optional design systems).

<Tabs items={["Full Stack (Lens)","Material 3 App","Custom Design System"]}>
<Tab value="Full Stack (Lens)">
```kotlin title="app/build.gradle.kts"
dependencies {
    implementation(project(":crow-ui"))
    implementation(project(":crow-router"))
    implementation(project(":crow-query"))
    implementation(project(":crow-store"))
    implementation(project(":crow-schema"))
    implementation(project(":crow-color"))
    implementation(project(":crow-motion"))
    implementation(project(":crow-lens"))
    implementation(project(":crow-symbols"))
    implementation(project(":crow-guide"))

    testImplementation(project(":crow-ui-test"))
    testImplementation(kotlin("test-junit"))
}
```
</Tab>

<Tab value="Material 3 App">
```kotlin title="app/build.gradle.kts"
dependencies {
    implementation(project(":crow-ui"))
    implementation(project(":crow-material3"))
    implementation(project(":crow-query"))
    implementation(project(":crow-motion"))
    implementation(project(":crow-symbols"))

    testImplementation(project(":crow-ui-test"))
    testImplementation(kotlin("test-junit"))
}
```
</Tab>

<Tab value="Custom Design System">
```kotlin title="app/build.gradle.kts"
dependencies {
    implementation(project(":crow-ui"))
    implementation(project(":crow-color"))
    implementation(project(":crow-motion"))
    implementation(project(":crow-symbols"))

    testImplementation(project(":crow-ui-test"))
    testImplementation(kotlin("test-junit"))
}
```
</Tab>
</Tabs>
</Step>
</Steps>

## Module Map [#module-map]

Crow separates **pure-JVM core modules** (verified Android-free by `gradle checkCorePurity`) from Android UI rendering, devtools, and optional design systems (verified by `gradle checkCoreIndependence`):

| Module | Layer | Target | Purpose |
| --- | --- | --- | --- |
| `crow-signals` | Core | JVM | Reactive graph: `signal`, `derived`, `effect`, `resource`, transitions, `action` |
| `crow-runtime` | Core | JVM | `@Ui`, `@Once`, `@Props`, `For`, `Loading`, `Errored`, `BackStack`, `NavHost`, `saved()` |
| `crow-compiler` | Compiler | K2 Plugin | K2 FIR checks (`CR1001`–`CR1003`, `CR2001`–`CR2007`), `$ui` lowering, `LocalGraph`, modifier & binding fusion |
| `crow-ui` | Renderer | Android | `LNode` tree, `RenderNode` chunks, layout, gestures, `crow.ui`, `crow.style`, AGSL glass engine |
| `crow-router` | Stack | JVM | Typed navigation & `crow.routes` file-based routing runtime |
| `crow-query` | Stack | JVM | Typed server-state cache (`query`, `infiniteQuery`, `QueryClient`, optimistic mutations) |
| `crow-store` | Stack | JVM | Reactive key/document store, codecs, migrations, crash-safe `FileStoreBackend` |
| `crow-state` | Stack | JVM | Structured app state containers and unidirectional state primitives |
| `crow-schema` | Stack | JVM | Zod-style validation DSL, `FormState`, cross-field rules, JSON Schema export |
| `crow-color` | Stack | JVM | Perceptual OKLab/OKLCH, WCAG/APCA contrast solver, palettes, artwork extraction |
| `crow-motion` | Stack | JVM | Analytic springs, `Animatable`, `animateFloat`, velocity-preserving retargeting |
| `crow-image` | Stack | JVM | Byte-budgeted LRU `ImageEngine`, cover-size hardware bitmaps, `imageResource` |
| `crow-inject` | Stack | JVM | Scoped lifetime dependency graphs with `Async` bindings and test overrides |
| `crow-guide` | Stack | Android | TipKit-style contextual tips and morphing spotlight tours across routes |
| `crow-media` | Stack | Android | Native Android media playback, gestures, and surface primitives |
| `crow-material3` | Design system | Android | Optional Material 3 components, live `ColorScheme`, dynamic wallpaper color |
| `crow-lens` | Design system | Android | Optional shadcn × Liquid Glass design system |
| `crow-symbols` | Icons | Android | 3,893 Material Symbols (Rounded/Outlined/Sharp + `SymbolStyle.Soft`) + variable axes + subsetter |
| `crow-codegen` | Tooling | JVM | Shared Android code generators for `@CrowApp` and `crow.routes` |
| `crow-build` | Tooling | JVM | Declarative `crow.jsonc` / `crow.lock`, zero-AGP Android APK pipeline, persistent `crow-daemon`, and project scaffolder |
| `crow-cli` | Tooling | Rust | Thin native `< 5 ms` `crow` CLI binary driving `crow-daemon` |
| `crow-live` | Tooling | JVM | Warm K2 compiler, delta-DEX Android hot-reload pusher, `LiveProtocol` v2 |
| `crow-live-android` | Tooling | Android | Debug-only on-device `CrowDevAgent` receiver, tree & signal-graph inspectors |
| `crow-ui-test` | Testing | Android/JVM | Headless Robolectric test harness: frames, gestures, semantics dumps, PNG snapshots |
| `crow-bom` | BOM | JVM | Bill of Materials aligning versions across all Crow library modules |

## Verify Your Workspace [#verify-your-workspace]

If you are working inside the Crow repository, run the core test suite and boundary checks with:

```bash
gradle :crow-signals:test :crow-runtime:test :crow-compiler:test \
  :crow-ui:testReleaseUnitTest :crow-ui-test:testReleaseUnitTest \
  checkCorePurity checkCoreIndependence checkDesignSystemHygiene
```