Skip to content
Latchkey

Android "No connected devices!" instrumented tests in CI

Instrumented tests run on a real device or emulator via connectedAndroidTest. On a CI runner there is no attached device by default, so the task fails with "No connected devices!" unless an emulator is booted first.

What this error means

The build fails with "com.android.builder.testing.api.DeviceException: No connected devices!" during connectedDebugAndroidTest or connectedCheck.

Android
> Execution failed for task ':app:connectedDebugAndroidTest'.
  > com.android.builder.testing.api.DeviceException: No connected devices!

Common causes

No emulator running on the runner

The instrumented test task needs an attached device; a default CI runner has none, so the device list is empty.

The emulator was not fully booted

An emulator was started but the task ran before it finished booting, so adb reports no online device.

How to fix it

Boot an emulator before the tests

Use the Android emulator runner action to start and wait for a booted emulator, then run the instrumented tests inside it.

.github/workflows/ci.yml
- uses: reactivecircus/android-emulator-runner@v2
  with:
    api-level: 30
    script: ./gradlew connectedDebugAndroidTest

Wait for the device to be ready

If you manage the emulator yourself, block until adb reports it booted before launching tests.

Terminal
adb wait-for-device shell 'while [ "$(getprop sys.boot_completed)" != 1 ]; do sleep 1; done'

How to prevent it

  • Start and wait for an emulator before connectedAndroidTest.
  • Use a managed emulator action that handles boot readiness.
  • Keep unit tests separate so they do not need a device.

Frequently asked questions

What causes ""No connected devices!""?
The instrumented test task needs an attached device; a default CI runner has none, so the device list is empty.
How do I fix "No connected devices!"?
Use the Android emulator runner action to start and wait for a booted emulator, then run the instrumented tests inside it.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card