# Editors and agents

> Code intelligence for Android projects through elide lsp (android.*, androidx.* and R), and the android/* tools elide mcp adds for agents.

## Language server

`elide lsp` resolves an Android project's Java sources against the classpath `elide install` exports under
`.dev/dependencies/m2/`. Run it once before starting the editor, and again after changing dependencies:

```bash
elide install
```

In an Android project the install also unpacks every `.aar` dependency and links the resources of every artifact,
so the exported classpath carries:

| From | Resolves |
| --- | --- |
| The `compileSdk` platform's `android.jar` | `android.*` |
| Each `.aar`'s `classes.jar`, and plain jars | `androidx.*`, Material, Play services, … |
| The generated `R` classes | `R.string.app_name`, `R.layout.main`, … |
| The test and instrumented-test classpaths | Robolectric, JUnit, AndroidX Test, Espresso |

Go to definition on an `R` field opens the generated `R.java` at that identifier. When the SDK has the platform's
sources (`sources;android-<N>`), hover and go to definition on a framework type read them:

```bash
sdkmanager --install 'sources;android-36'
```

- The server has one classpath for every file under its root, so a `src/androidTest` file also sees host-test
  libraries, a `src/test` file instrumented-test libraries, and a `src/main` import of a test-only library raises
  no diagnostic; the build keeps the scopes apart and reports it.
- Definition on a JDK class reads the `lib/src.zip` of the JDK `JAVA_HOME` names; Elide does not ship one
  ([Other editors](https://elide.help/docs/connect-ide)).
- A resource added after the install resolves once `R` is rebuilt, by `elide build` or `elide install`, and the
  server restarted.
- No `BuildConfig` class exists to resolve: Elide does not generate one.
- Kotlin sources are not served by `elide lsp`.

Editor setup: [IDE integration](https://elide.help/docs/ide), [Other editors](https://elide.help/docs/connect-ide).

## Compose previews

Debug builds compile Compose code with source information, so preview tooling can locate each composable call
([Kotlin compiler](https://elide.help/docs/toolchain/jvm/kotlinc#compose)). The template declares the `ui-tooling` module, which
carries the activity a device-side Compose preview launches; keep tooling modules in debug artifacts.

## Agents

`elide mcp` in a project whose `elide.pkl` declares `android`, or a workspace root with such a member, adds tools
for driving the project. In any other project they are not listed.

| Tool | Runs | Mirrors |
| --- | --- | --- |
| `android/sdk` | Nothing: reads the SDK | `elide project info` |
| `android/sdk/install` | `android-sdk`, installing | `elide install --accept-android-licenses` |
| `android/devices` | Nothing: asks `adb` and `avdmanager` | `elide project info` |
| `android/avd` | `android-avd` | `elide build android-avd` |
| `android/emulator/start` | `android-emulator`, headless by default | `elide build android-emulator` |
| `android/emulator/stop` | `android-emulator-stop` | `elide build android-emulator-stop` |
| `android/run` | `android-run[-emulator]-<app> --no-follow` | `elide run` |
| `android/test` | `android-test-<app>[-on-<device>]` | `elide test --device` |
| `android/test/host` | The host tests | `elide test` |

- Each tool runs the build target its command runs, chosen by the same rules, so the two never disagree.
- Nothing is installed unless the call passes `acceptLicenses: true`. `android/sdk/install` requires it; a license
  recorded in the SDK does not stand in for it.
- `android/run` returns once the app has launched, with the device, package and activity, whether the app is still
  running after `logWaitMs` (default 2000, at most 30000), and the last `logLines` lines of its log (default 200, at
  most 2000), or of the crash buffer if the app has died.
- `android/test` returns each device's totals, whether the run finished, and every test's outcome with a failure's
  stack trace; `android/test/host` every host test's status and failure message.
- A failed build returns `outcome: "failure"` and up to 100 of the warnings and errors it reported. A request
  the project cannot satisfy (no application, several and none named, nothing instrumented) is a tool error naming
  what exists.

The `android` template's MCP option writes a `.mcp.json` that registers `elide mcp`. Client setup and the other tools:
[Project MCP server](https://elide.help/docs/mcp).
