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.
> 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.
- uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 30
script: ./gradlew connectedDebugAndroidTestWait for the device to be ready
If you manage the emulator yourself, block until adb reports it booted before launching tests.
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.