CLI
Install the spawndroid CLI, write a spec, and run your Android suite on hosted devices from any machine or pipeline.
The CLI is the shortest path from an Android project to a green run on a hosted device. It owns the whole journey — upload, runner, readiness, fixtures, your test command, the JUnit report and teardown — so a pipeline needs one step instead of four API calls.
Install
The package is spawndroid on npm and needs Node 20 or newer.
npx spawndroid run # nothing to install
npm install --global spawndroid # or install it once
npm install --save-dev spawndroid # or pin it with the projectThe source and the companion GitHub Action live at spawndroid/cli.
Quick start
npx spawndroid init # detect the project, write spawndroid.yaml + a GitHub workflow
export SPAWNDROID_API_KEY=spawn_live_… # API & CI/CD → API keys, upload scope
npx spawndroid check # key, APK, report and plan walls before the first run
npx spawndroid run # upload → boot → test → JUnit → teardowninit reads the project (Gradle, Maven, WebdriverIO, pytest), prints what it inferred, and asks only for the gaps. When it cannot find an APK or a test command it stops and says which flag to pass. Every value is overridable:
npx spawndroid init --app app/build/outputs/apk/debug/app-debug.apk \
--command "mvn test" \
--report target/surefire-reports/TEST-com.example.CheckoutTest.xml \
--profile android-14-phone --no-workflowThe spec
spawndroid.yaml is committed to the repository. Unknown keys are errors — a misspelled timeout must not silently fall back to the default.
version: 1
app: app/build/outputs/apk/debug/app-debug.apk # APK path, or an uploaded app slug
command: [mvn, test] # string is split; list is exact argv
profile: android-14-phone # optional device profile
report: target/surefire-reports/TEST-….xml # one JUnit XML file
timeout: 600 # seconds to wait for the device
fixtures: # optional, pushed after readiness
- local: test/fixtures/sample.jpg
device: /sdcard/Pictures # absolute directory under /sdcard| Field | Required | Meaning |
|---|---|---|
version | yes | Must be 1. |
app | yes | APK/AAB path relative to the spec, or an uploaded app slug. A path is uploaded on every run; a slug reuses the stored build. |
command | yes | Run locally on the machine or runner, with the session in its environment. A string is split on whitespace; a list is exact argv (use the list form for quoting). |
profile | no | Device profile id, e.g. android-14-phone. |
report | no | One JUnit XML file to attach. A directory or glob is rejected by check. |
timeout | no | Seconds to wait for the device. Default 600; the host needs up to ~420 s plus one boot retry. |
fixtures | no | Files pushed onto the device after it is ready. Up to 32 MB each. |
Commands
spawndroid init [--app <apk>] [--command <cmd>] [--report <xml>] [--profile <id>] [--force] [--no-workflow]
spawndroid check [--config <path>]
spawndroid run [--config <path>] [--profile <id>] [--timeout <s>] [-- <command…>]
spawndroid upload <app.apk> [--json]
spawndroid start --app <slug> [--profile <id>] [--json]
spawndroid wait <sessionId> [--timeout <s>] [--json]
spawndroid report <sessionId> --result passed|failed
spawndroid --versionupload, start, wait and report are the step-by-step form, for pipelines that drive the API themselves. run is the whole journey.
What run does
- Uploads the APK (or reuses an uploaded build when
appis a slug), creating a session with anIdempotency-Key. - Retries a capacity
429, a502/503/504, or a network failure a few times with the same key. Plan limits (PLAN_RUNNER_LIMIT,PLAN_DEVICE_MINUTES_EXHAUSTED) fail immediately. - Waits up to
timeoutfor the device, tolerating transient gateway errors, then pushes fixtures. - Runs
commandfrom the spec's directory with the session in its environment. - Posts the JUnit report, tears the device down, and prints the run URL.
Exported to the command:
| Variable | Meaning |
|---|---|
SPAWNDROID_WD_URL | W3C WebDriver endpoint for the session |
SPAWNDROID_UDID | Device serial |
SPAWNDROID_APP_PACKAGE | Installed app package |
SPAWNDROID_APP | App slug |
SPAWNDROID_SESSION_ID | Session id |
The build is installed before the command runs — never set appium:app or appium:appPackage; your suite launches the app.
Exit codes
| Code | Meaning |
|---|---|
0 | The suite passed. |
1 | The suite failed. |
2 | The run could not happen (setup, plan limit, host, timeout). |
CI retry logic should retry 2 and never 1.
Limits
- Appium/WebDriver suites only: a session exposes a WebDriver endpoint, not adb, and installs exactly one APK.
- CI runs are not capped by your plan's session length: they run to the host ceiling (one hour by default) and their real minutes count against the monthly allowance. Manual sessions keep the plan cap.
- Hobby builds expire 7 days after upload;
BUILD_EXPIREDmeans re-upload.
Failures name the registry code and print a hint. The full symptom-to-fix table lives in CI tests.
GitHub Actions
- uses: spawndroid/cli@v0.1.8
with:
api-key: ${{ secrets.SPAWNDROID_API_KEY }}The Action installs the CLI and runs spawndroid run --config spawndroid.yaml. init writes the workflow for you.
Was this page helpful?