Android UI checks in CI when the runner has no KVM.

Check the runner first

Run ls /dev/kvm in a job. If the file is missing, the emulator can't use acceleration there. Docker-based runners often hide it even when the host has it. Android emulators in cloud sandboxes lists what each coding-agent sandbox documents.

Three ways to run the check

Running Android UI checks from a CI runner without KVM
RunsYou changeCost
A runner with KVMYour Espresso or Maestro suite on an emulatorThe runner: self-hosted, or a hosted one that exposes KVMRunner minutes, plus boot time on every job
A cloud Android phone (Phonebox)CLI checks, or a coding agent's exploratory passA few job steps; the phone is reused between runs$0.06 a minute while it runs, parked free
A device cloudYour instrumented suite on real devicesUpload the app and test APKs from the jobFrom $199 a month per parallel; AWS $0.17 a device-minute

A GitLab CI job

Create one phone for CI and save its ID and an API key as the CI/CD variables PHONEBOX_PHONE and PHONEBOX_API_KEY. This job takes the APK from your build job, installs it, checks the first screen and parks the phone:

.gitlab-ci.yml
android-smoke:
  stage: test
  image: node:20
  needs: [build]                    # the job that produced the APK as an artifact
  resource_group: phonebox-phone    # one pipeline per phone at a time
  script:
    - npm install -g https://phonebox.dev/downloads/phonebox-0.1.0.tgz
    - phonebox start
    - phonebox apps install app/build/outputs/apk/debug/app-debug.apk
    - phonebox open com.example.app
    - phonebox wait --text "Welcome" --timeout 30s
  after_script:
    - phonebox park

resource_group keeps two pipelines from driving the same phone at once. phonebox wait exits with code 3 when the text doesn't appear, which fails the job, and after_script parks the phone either way. The same steps work in any CI system; the GitHub Actions version is in Android checks in GitHub Actions.

On every pull request, or nightly

  • Every pull request: a one-screen smoke check takes about a minute of phone time, so 100 pull requests a month cost about $6.
  • Nightly: run a longer pass on a schedule, and let a coding agent explore the screens that changed that day; see Run it every day.
  • Keep the scripted suite for regressions you already know about; use the phone for checks that would be expensive to script.

Questions

Can I run the Android emulator in CI without KVM?

Not usefully. The emulator needs hardware virtualization, KVM on Linux, and Android describes software emulation without it as not supported and very slow. Use a runner that exposes KVM, a device cloud, or a cloud Android phone driven over the network.

How do I run Android tests in GitLab CI?

If your runner exposes /dev/kvm, boot the emulator in the job. If it doesn't, either send instrumented tests to a device cloud, or install the Phonebox CLI in a Node.js job, install the APK on a cloud Android phone, check the screen with phonebox wait, and park the phone in after_script.

What do teams use instead of the Android emulator in CI?

Device clouds such as BrowserStack, AWS Device Farm and Firebase Test Lab for instrumented suites, and cloud Android phones for smoke checks and agent-driven passes. Robolectric covers tests that can run on the JVM without a device.

What does a CI smoke check on a cloud phone cost?

Phonebox bills $0.06 a phone-minute, per second with a one-minute minimum, so a one-minute check is $0.06 and a parked phone between runs is free.

Get started with Phonebox. New accounts start with a free 7-day trial, card required.

The Phonebox team

← All guides