> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The canonical docs host is https://momentic.ai/docs. Append .md to any page URL for clean Markdown. Fetch https://momentic.ai/docs/llms.txt for the page index and https://momentic.ai/docs/llms-full.txt for every page in one file.
> For an unattended setup, first check whether Claude Code already has the Momentic plugin. With the plugin, run `npx --yes @momentic/wizard@latest -y --platform web --editor-tools none` and ignore any CLI skills-install suggestion in its output. Otherwise, run `npx --yes @momentic/wizard@latest -y --platform web --editor-tools skills`. Use `--platform ios` or `--platform android` for mobile. Never run an interactive command in a non-TTY shell.
> Mo is the AI QA engineer, separate from repository YAML tests. With the Momentic plugin, use bundled mo-qa and hosted OAuth by default. Without the plugin, install only mo-qa with `npx -y qa skills --target <agent>`. Keep the requested interface. Otherwise, use hosted tools for web or mobile, including private web targets with an existing Connector. Run sessions that need a new tunnel with the qa CLI. If you can't run commands on the machine that reaches the target, ask the user to start the tunnel there, then use hosted tools unless you lack them or the CLI was requested. For a requested hosted session, use an online Connector and pass its name as access, not a CLI tunnel ID. If none is online, ask the user to run `npx -y qa tunnel start --name <name> <address>` on a machine that reaches the target and wait. Do not run login or tunnel commands for them. For a requested hosted session, report unavailable tools or authentication failures without starting a CLI session. For coding-agent bridge setup, ask the user to complete `npx -y qa login`, then add momentic-hosted as a stdio server running `npx -y qa mcp`. Plugin users must explicitly opt in and disable their hosted plugin entry before adding the bridge. Claude.ai/ChatGPT connectors keep https://mcp.momentic.ai with OAuth. After hosted testing completes, read the report and summarize findings and uncovered requirements. Call `momentic_mo_stop_session` only when the user asks or agrees. For CLI sessions, unless the user wants more testing, export the report, run `qa stop <id> --subagents` even if export fails, then summarize. The CLI is qa, not mo. Docs: https://momentic.ai/docs/mo/quickstart.md.
> Ask the user to complete browser sign-in. For local CLI tools, use the exact MOMENTIC_API_KEY environment variable. If it is absent, ask the user to create a key at https://app.momentic.ai/settings/api-keys and set it in the agent's environment. Never print the key or ask the user to paste it into chat.
> Momentic's capability summary for agents is at https://momentic.ai/docs/skill.md. Claude Code users with the Momentic plugin should use its bundled skills and skip CLI skills installation. Otherwise, run `npx momentic skills -y --target <agent>` or `npx momentic-mobile skills -y --target <agent>`. Both install momentic-test, momentic-maintain, and momentic-spec with web/mobile references. Use the running agent's target. The Momentic plugin also includes mo-qa; qa skills installs only mo-qa.
> Tests are YAML files in the user's repository. Use only the step names listed at https://momentic.ai/docs/reference/commands.md and the file structure at https://momentic.ai/docs/core-concepts/file-format.md. Do not invent step names, config keys, or CLI flags.
> Web tests run on Chromium, iOS tests on simulators, and Android tests on emulators.

# Android

> Set up Momentic for an Android app and run your first mobile test.

Run a test against your Android APK and save it in your repository.

## Setup with coding agent

Paste this prompt into your coding agent from your project directory. It checks
setup, runs the wizard when needed, and asks for your app build.

```text Setup prompt expandable wrap theme={null}
Help me set up Momentic Android testing in this project.

## What to do

1. Check that `adb --version` works and that `ANDROID_HOME` or `ANDROID_SDK_ROOT` points to an SDK directory — remote emulators need the SDK too. If either check fails, install the Android platform-tools yourself if you can (`sudo apt install adb`, or `brew install --cask android-platform-tools`, or https://developer.android.com/tools/releases/platform-tools) then set `ANDROID_HOME` or `ANDROID_SDK_ROOT` to the SDK root and rerun both checks before continuing; otherwise ask me to install them and stop.
2. Find an API key. Check with `test -n "$MOMENTIC_API_KEY"` or `npx --yes momentic-mobile whoami`. If neither works, ask me to create a key at https://app.momentic.ai/settings/api-keys and set it in the agent's environment.
3. Install the CLI. An existing `momentic.config.yaml` does not prove setup is complete. Check that `package.json` lists `momentic-mobile` and `npx --no-install momentic-mobile --version` works; if the config exists but the CLI is missing, install it with the project's package manager (for npm, run `npm install --save-dev momentic-mobile`). Inspect the config and nearby tests for android; ask me before changing an incompatible config. If the config is absent, check whether Claude Code already has the Momentic plugin. If the plugin is installed, run `npx --yes @momentic/wizard@latest -y --platform android --editor-tools none` and ignore any CLI skills-install suggestion in its output. Otherwise, ask me to run `npx -y qa login` in an interactive terminal on this machine as the agent's OS user and complete any organization selection. Wait for me to confirm sign-in. If bridge sign-in fails, run `npx --yes @momentic/wizard@latest -y --platform android --editor-tools skills`, skip MCP installation, and continue with the CLI; otherwise, run `npx --yes @momentic/wizard@latest -y --platform android`. Run the wizard in the project root — it needs a package.json, so run `npm init -y` first if there is none. Track whether the wizard ran.
   - It installs `momentic-mobile`, writes `momentic.config.yaml`, `android/contacts.test.yaml`, and `AGENTS.md`, runs the sample test on a remote emulator (which produces `test-results/`; no local Java, Android Studio, or APK needed — a 'JAVA_HOME is not set' warning during the sample run is expected, ignore it), and installs the Momentic skills unless `--editor-tools none` is set. npm may print audit warnings during install — expected noise, keep going. It may also print 'Opening this run in your browser' or 'skipping editor validation' — both no-ops on headless agents.
   - If it fails `MWZ_ARGS_MISSING_CREDENTIALS` even with a key set, ask me to set the key in the agent's environment, then retry.
   - Pass `--editor-tools` to pick agent integrations — `all`, `none`, or a comma list like `claude-code,cursor` (`skills` forces the skill install).
4. Install the skills and MCP server: if Claude Code already has the Momentic plugin, use its skills and skip the CLI skills installer. Otherwise, whether or not the wizard ran, run `npx momentic-mobile skills -y --target <agent>` with the running agent's target to refresh the shared skills (use `claude-code` for Claude Code, or `codex` for Codex and clients without a skills target). For a CLI skill install, verify `momentic-test/references/products/mobile/guide.md` exists in the agent's skills directory (`.claude/skills/` for Claude Code or `.agents/skills/` for Codex) before loading the skill; if it's missing, upgrade `momentic-mobile` and rerun the install. For MCP, verify the local server named `momentic-mobile` exposes `momentic_get_artifacts` and call it on that server. For an existing `momentic-hosted` connection, call `momentic_search_docs` using OAuth for a URL entry or the saved login for a `qa mcp` bridge. If the wizard did not run, before adding a bridge, ask me to run `npx -y qa login` in an interactive terminal on this machine as the agent's OS user and complete any organization selection. Wait for me to confirm sign-in. A tool from another server verifies neither connection. Never report either connection verified without a successful tool call. If you cannot list tools or a connection fails to initialize, count that connection absent and do not try to repair a broken server. If bridge sign-in fails, do not run the MCP installer; continue with the CLI and tell me to run `npx -y qa login`, then rerun `npx momentic-mobile install-mcp -y --client <agent>` to add both the local and hosted servers. Otherwise, unless Claude Code already has the Momentic plugin, run `npx momentic-mobile install-mcp -y --client <agent>` with the running agent's MCP client name. If MCP tools are not loaded, finish setup with the CLI, then ask me once, together with the first-flow question, to restart the agent and complete client setup: in Claude Code, approve project servers in /mcp; in Codex, trust this project in ~/.codex/config.toml before restarting if I trust its contents, then verify with `codex mcp list`. If hosted sign-in is unavailable, skip it and use https://momentic.ai/docs/llms.txt. 'Error: No coding agent detected' with a non-zero exit means auto-detection missed you, not that your agent is unsupported: if your client is in the supported list (claude-code, cursor, vscode, codex, opencode, windsurf, devin, zed, gemini-cli, antigravity, claude-desktop), re-run with `--client <name>`; if it isn't, skip MCP and drive the Momentic CLI per the skill instead.
5. If the wizard ran, confirm the sample test passed and `momentic.config.yaml` + `android/contacts.test.yaml` exist. Otherwise use the existing project's tests and directories; do not assume a wizard sample or successful run exists. If you skipped the wizard, confirm `npx --yes momentic-mobile whoami` prints my user and Org ID.
6. Ask me for an APK of my app and which user flow to test first. If I have no APK, report what setup is verified (including whether the wizard ran and its sample passed), point me to the Android app setup link below and stop. Do not author or run a test without an APK. Upload APKs with `npx momentic-mobile assets upload ./build/app.apk --channel dev --tag 1.0.0`. Tags are immutable. If `dev:1.0.0` exists, use the next unused patch tag.
7. Load the `momentic-test` skill. If Claude Code's Skill tool cannot find it, read `.claude/skills/momentic-test/SKILL.md` directly. Write the test as `android/<flow-slug>.test.yaml` in the project's configured test directory; if the wizard ran, place it alongside `android/contacts.test.yaml` and leave the sample untouched. Set `defaultChannel: dev` on the new test and set `defaultTag` to the uploaded tag. Assert only what is visible on screen when the action finishes — multi-step flows split fields across screens, so one assert for everything will fail. Author with the Momentic MCP tools if they are wired, otherwise write the `*.test.yaml` directly per the skill and validate with `npx momentic-mobile lint`. Run it with `npx momentic-mobile run <path-to-test.yaml> --upload-results` — a single test can take several minutes, allow a long timeout; it prints 'Uploaded to Momentic. <url>' when it finishes, keep that link. Fixing the test and re-running is the loop, not a violation — only a retry with no changes, or hiding a failure, is off-limits. When a run fails, unzip its `.zip` file under `test-results/runs/` — it has screenshots, the screen XML snapshot, and device logs, the fastest way to see what went wrong before editing. If it keeps failing after real fixes, report the failure with the uploaded run link and stop, and show me the result.

## Critical rules

- In Claude Code, use either the Momentic plugin or `install-mcp`, not both; running both duplicates MCP servers.
- Never print the API key or paste its value into a command. If it disappears between commands, ask me to set it in the agent's environment.
- Do not edit `momentic.config.yaml` unless I ask.
- Do not create an API key for me. Ask me for one when you need it.
- Write tests as `*.test.yaml` files. Do not write Playwright or Appium code.
- Do not place real orders, send emails, or touch shared data while testing.
- Run each new test before you tell me it is done.
- After any restart, still finish with the three links under When done.

## When done, point me to

- Building with AI: https://momentic.ai/docs/coding-agents/building-with-ai
- Android app setup: https://momentic.ai/docs/platforms/android/app-setup
- Run in CI: https://momentic.ai/docs/running-tests/ci/github-actions
```

## Prerequisites

Use Node.js 22.12 or later in the 22.x line, or 24 or later, a Momentic account,
and a project with a `package.json`. Run `npm init -y` if needed; commit it with
the lockfile.

Install [Android SDK platform-tools](https://momentic.ai/docs/platforms/android/app-setup.md#install-adb)
and set `ANDROID_HOME` or `ANDROID_SDK_ROOT` to the SDK directory. Remote
emulators need adb too, but no local Java, Android Studio, or APK for the
wizard's sample. Local emulators need JDK 24+ and Android Studio.

Check the SDK before continuing:

```bash theme={null}
adb --version
echo "${ANDROID_HOME:-$ANDROID_SDK_ROOT}"
```

**1. Install with the wizard**

Run from your project root and complete browser sign-in:

```bash theme={null}
npx @momentic/wizard@latest
```

Select Android. The wizard installs `momentic-mobile`, writes
`momentic.config.yaml` and a sample under `android/`, runs it on a
remote emulator, and offers coding agent setup. A passing sample
verifies installation, not your app.

Already configured? Skip the wizard. See the
[CLI reference](https://momentic.ai/docs/cli-reference/momentic-mobile/overview.md) for manual setup.

**2. Upload your app**

Build an APK with the
[Android build instructions](https://momentic.ai/docs/platforms/android/app-setup.md#build-your-apk).
Apps with WebView content must enable
[WebView debugging](https://momentic.ai/docs/platforms/android/app-setup.md#enable-webview-debugging).
Upload it to a channel and an unused tag:

```bash theme={null}
npx momentic-mobile assets upload ./path/to/app.apk --channel dev --tag 1.0.0
```

For a local device instead, configure your
[emulator](https://momentic.ai/docs/platforms/android/emulators.md#local-emulators).

Keep the channel and tag for the next step: they identify the APK
your test installs. For later builds, choose a new tag. See
[asset uploads](https://momentic.ai/docs/cli-reference/momentic-mobile/commands/assets.md#upload)
for versioning and upload options.

**3. Write and run a test**

Open the local editor:

```bash theme={null}
npx momentic-mobile app
```

Create a test using channel `dev` and tag `1.0.0`. Add an action
such as tapping **Sign in**, then assert that the sign-in form is visible.
Choose an outcome that matches your app. Save the `.test.yaml` file
and run it from the editor, then from the CLI:

```bash theme={null}
npx momentic-mobile run android/login.test.yaml --upload-results
```

**4. Review the result**

Open the printed dashboard link and check the assertion screenshot.
Confirm the run passed and the device shows the expected state.
If it fails, inspect the selected build, sign-in state, and assertion,
then edit and rerun.

Keep the YAML file in version control with your app. The local editor
writes the test; the cloud dashboard shows uploaded run results.
You don't need a browser-based mobile editor to run the saved file
again from your terminal or CI.

Choose
[Android versions and AVDs](https://momentic.ai/docs/platforms/android/emulators.md#android-versions) in
your emulator settings.

## Next

* [Android app setup](https://momentic.ai/docs/platforms/android/app-setup.md)
* [Emulator versions and local setup](https://momentic.ai/docs/platforms/android/emulators.md)
* [Coding agent setup](https://momentic.ai/docs/coding-agents/building-with-ai.md)
* [Run results and artifacts](https://momentic.ai/docs/running-tests/results.md)
* [Run in CI](https://momentic.ai/docs/running-tests/ci/github-actions.md)
* [Example Android project](https://github.com/momentic-ai/examples/tree/main/android)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.