Verify an Android app change on the user's real Android phone - build, install, open, drive the changed screens with CodeDroid, check logcat for crashes, run instrumentation tests, and report what was seen. Use after changing Android app code, when asked to test, reproduce or verify something on a device, or before saying an Android change works. For an app's CUJs and test cases end to end, use app-e2e.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Test On Device?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/codedroid-team-test-on-device-codedroid-mcp)
---
name: test-on-device
description: Verify an Android app change on the user's real Android phone - build, install, open, drive the changed screens with CodeDroid, check logcat for crashes, run instrumentation tests, and report what was seen. Use after changing Android app code, when asked to test, reproduce or verify something on a device, or before saying an Android change works. For an app's CUJs and test cases end to end, use app-e2e.
---
# Testing an Android change on the phone
CodeDroid's tools (`get_screen`, `tap`, `type_text`, `wait_for`, `take_screenshot`, ...) see and
drive the screen exactly as it is; the codedroid-phone skill covers them. adb, from the Android
SDK on this computer, installs, starts and inspects the app. Use adb to install and inspect; use
CodeDroid to look and act.
<!-- directory:omit -->
With the local bridge, `adb` is a tool that runs this computer's adb, and `install_apk` installs
with no cable. The user can turn the `adb` tool off (`--no-adb` or `CODEDROID_MCP_ADB=0`).
<!-- /directory:omit -->
When `adb` is not in your tool list (CodeDroid's hosted server has none), run the adb commands
below with your own shell tool when the phone is on this computer's adb (`adb devices -l` says),
ask the user to run them otherwise, and read the steps that follow as what to do rather than
which tool. Without adb, CodeDroid's tools still drive and check the app: say in the report
which checks adb would have made.
## 1. Know the phone
CodeDroid reaches the phone through the CodeDroid server; adb needs it on this computer, over USB
or Wireless debugging. Call <!-- directory:omit -->`codedroid_status` (local bridge) or <!-- /directory:omit -->`codedroid_devices`<!-- directory:omit --> (remote
connector)<!-- /directory:omit -->, then `device_info` for the phone's model and
Android `user`, and `adb` `devices -l` to find the same model there. If adb lists none, go on
without it, or ask the user to connect it for logs and instrumentation tests; if it lists several, pass <!-- directory:omit -->the same `device` to `adb` as to the phone tools, or <!-- /directory:omit -->`-s <serial>`<!-- directory:omit --> when two are the same model<!-- /directory:omit -->. On a phone with
several users (a Googlebook runs as user 10), adb's `settings`, `content`, `pm grant` and
`appops` default to user 0: add `--user <user>` to them. `adb install` covers every user.
## 2. Build and install
1. Build with the project's own task, e.g. `./gradlew :app:assembleDebug` (check the module and
variant names in the project first).
2. Install `app/build/outputs/apk/debug/app-debug.apk`<!-- directory:omit --> with `install_apk`: it needs no cable,
keeps the app's data, and says what went in<!-- /directory:omit -->. On a phone attached to adb, `adb`
`install -r -g <apk>` keeps the app's data and grants its runtime permissions<!-- directory:omit -->; without
`install_apk`, it is how to install<!-- /directory:omit -->: run it yourself if the phone is on this computer's adb,
or ask the user to. A signature mismatch means the phone has another build: ask the user before
removing it, which deletes the app's data.
3. If the phone is on adb, `adb` `logcat -c` to clear the logs, so what you read later is from this run.
## 3. Open it and drive the change
1. `open_app` with the package, or `adb` `shell am start -W -n <package>/<activity>`. For a deep
link: `shell am start -W -a android.intent.action.VIEW -d "<uri>" <package>`.
2. `wait_for` text on the first screen, rather than sleeping.
3. Walk to the changed screen with `get_screen` and `tap` / `type_text` / `swipe`, reading
`after` each time.
4. Check what the change should show: the text and state in `get_screen` (a switch is `checked`
or `unchecked`, a field shows its text), and `take_screenshot` for anything visual.
5. Try the edges the change touches: empty input, rotation (`adb` `shell settings put system
user_rotation 1` after `shell settings put system accelerometer_rotation 0`), dark theme
(`shell cmd uimode night yes`), back navigation. Put settings back afterwards.
## 4. Check the logs
- Crashes: `adb` `logcat -d -b crash`. A crash kills the process, so read the crash buffer
rather than filtering by process id.
- Errors: `logcat -d -t 300 *:E`; one app's lines: `shell pidof <package>`, then
`logcat -d --pid=<pid>`.
- ANRs: `shell logcat -d -b system | grep -A5 "ANR in"` (after `shell`, the pipe runs on the phone).
## 5. Instrumentation tests
`adb` `shell am instrument -w -r -e class <fully.qualified.TestClass> <test-package>/androidx.test.runner.AndroidJUnitRunner`
<!-- directory:omit -->with `timeout_s` set for the run <!-- /directory:omit -->(install the test APK first:
`./gradlew :app:installDebugAndroidTest`).<!-- directory:omit --> The reply sums up the run: the counts and each failure's
stack.<!-- /directory:omit --> If the run itself did not finish (a crash, a timeout, no tests ran), read the
crash buffer as in section 4. Tests that use UiAutomator suspend CodeDroid's accessibility
while they run: call <!-- directory:omit -->`codedroid_status` or <!-- /directory:omit -->`device_info` before using its tools again.
## 6. Report
Say what you checked and what you saw, step by step, and whether the change works. Include a
screenshot when the change is visual (`take_screenshot`; if CodeDroid is suspended, `adb`
`exec-out screencap -p`<!-- directory:omit --> with `save_to`<!-- /directory:omit --> into a file), and the crash's stack trace (from `logcat -d -b crash`)
when there was one. If something could not be checked (the phone was locked, a screen could not
be reached), say so rather than guessing.
<!-- directory:omit -->
## The app's e2e test cases
An app's journeys and test cases, and running them all with a report, are the app-e2e skills'
(`e2e/` in the app's repo). To check one change against them, run just the cases for the journeys
it touches, as app-e2e-rerun's "The cases a change touches" says.
<!-- /directory:omit -->
## Never
- Force-stop, clear, uninstall or `am instrument` com.codedroid.agent: it switches CodeDroid off.
- Uninstall an app, clear its data, reboot or delete files without asking the user first.
- Stream: `logcat` without `-d` and `screenrecord` without `--time-limit` run until the call
times out.