Skip to Content
Spawndroid

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 project

The 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 → teardown

init 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-workflow

The 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
FieldRequiredMeaning
versionyesMust be 1.
appyesAPK/AAB path relative to the spec, or an uploaded app slug. A path is uploaded on every run; a slug reuses the stored build.
commandyesRun 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).
profilenoDevice profile id, e.g. android-14-phone.
reportnoOne JUnit XML file to attach. A directory or glob is rejected by check.
timeoutnoSeconds to wait for the device. Default 600; the host needs up to ~420 s plus one boot retry.
fixturesnoFiles 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 --version

upload, 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

  1. Uploads the APK (or reuses an uploaded build when app is a slug), creating a session with an Idempotency-Key.
  2. Retries a capacity 429, a 502/503/504, or a network failure a few times with the same key. Plan limits (PLAN_RUNNER_LIMIT, PLAN_DEVICE_MINUTES_EXHAUSTED) fail immediately.
  3. Waits up to timeout for the device, tolerating transient gateway errors, then pushes fixtures.
  4. Runs command from the spec's directory with the session in its environment.
  5. Posts the JUnit report, tears the device down, and prints the run URL.

Exported to the command:

VariableMeaning
SPAWNDROID_WD_URLW3C WebDriver endpoint for the session
SPAWNDROID_UDIDDevice serial
SPAWNDROID_APP_PACKAGEInstalled app package
SPAWNDROID_APPApp slug
SPAWNDROID_SESSION_IDSession id

The build is installed before the command runs — never set appium:app or appium:appPackage; your suite launches the app.

Exit codes

CodeMeaning
0The suite passed.
1The suite failed.
2The 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_EXPIRED means 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?

On this page