Run Android Tests on Real Phones in GitHub Actions (2026)
Emulators in CI are fine until your app cares about being on a real device. The moment a fraud SDK, a sensor check, or a region lock enters the picture, your green pipeline stops meaning anything. Pointing GitHub Actions at a real cloud phone fixes that: the runner connects over network adb, runs your suite against an actual handset, and reports back like any other job. Here’s the full workflow.
I run a real cloud phone farm, so this is the practical CI setup, including the parts that fail quietly the first time you try it on a hosted runner.
the shape of it
A GitHub Actions runner is a throwaway Linux box with no phone attached. To test on a real device, the runner connects out to a cloud phone over adb, installs your build, runs the tests, and tears down the connection. The phone lives elsewhere and stays up between runs; the runner is the disposable part.
The pieces you need: platform-tools on the runner for adb, the phone’s address and any auth as secrets, and a test runner (Appium, Espresso via adb, or instrumented tests). The phone being reachable is a setup step, not part of the test.
store the connection details as secrets
Never hardcode the device host. Put it in repository secrets so it’s not in the workflow file or the logs:
CLOUD_PHONE_HOSTthe host:port for adbCLOUD_PHONE_TOKENany auth token your provider uses to authorise the adb connection
Reference them as ${{ secrets.CLOUD_PHONE_HOST }} in the workflow. GitHub masks secret values in logs, but be careful not to echo them into a command that prints, because a masked value can still leak if you transform it first.
the workflow
Here’s a working .github/workflows/android-device-tests.yml. It sets up adb, connects to the phone with a retry, installs the build, runs the suite, and always disconnects at the end:
name: android device tests
on: [push, pull_request]
jobs:
device-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up android platform-tools
uses: android-actions/setup-android@v3
- name: build debug apk
run: ./gradlew assembleDebug
- name: connect to cloud phone
env:
PHONE: ${{ secrets.CLOUD_PHONE_HOST }}
run: |
for i in 1 2 3 4 5; do
adb connect "$PHONE" && sleep 2
if adb devices | grep -q "${PHONE}.*device"; then
echo "connected"; break
fi
echo "retry $i"; adb disconnect "$PHONE"; sleep 5
done
adb devices
- name: install build
env:
PHONE: ${{ secrets.CLOUD_PHONE_HOST }}
run: adb -s "$PHONE" install -r app/build/outputs/apk/debug/app-debug.apk
- name: run tests
env:
PHONE: ${{ secrets.CLOUD_PHONE_HOST }}
run: ANDROID_SERIAL="$PHONE" ./gradlew connectedDebugAndroidTest
- name: disconnect
if: always()
env:
PHONE: ${{ secrets.CLOUD_PHONE_HOST }}
run: adb disconnect "$PHONE"
The if: always() on the disconnect step is not optional. If a test fails and the job stops, you still want to release the device cleanly so the next run doesn’t trip over a stale connection.
the connect retry is the whole game
The number one cause of flaky device CI is the adb connect racing against the network. A hosted runner cold-starts every time, so the first adb connect often returns before the tunnel is actually up, and adb devices shows offline. The retry loop above handles it: connect, wait, check for the device state, and only proceed once it’s real. Treat a missing device as a setup failure, not a test failure, so you can tell “the phone wasn’t reachable” apart from “the app is broken”.
CI-specific gotchas
| Problem | What’s happening | Fix |
|---|---|---|
device shows offline |
connect raced the tunnel | retry loop with a state check |
adb server version doesn't match |
runner’s adb is stale | use setup-android to get current platform-tools |
| install fails with signature error | previous build signed differently | adb uninstall <pkg> before install |
| tests hang then time out | default adb timeouts too low for remote | raise timeouts; for Appium bump adbExecTimeout |
| two PRs grab the same phone | concurrent jobs, one device | use a concurrency group to serialise |
That last one bites teams as they grow. Two pull requests trigger at once, both try to drive the same phone, and they corrupt each other’s state. Add a concurrency group so device jobs queue instead of colliding:
concurrency:
group: cloud-phone-device
cancel-in-progress: false
cancel-in-progress: false means a running test finishes rather than getting killed by a newer push, which is what you want when a real device is mid-test.
scaling to a matrix of phones
Once one phone works, a matrix across several real devices is a small step. Put each phone’s address in its own secret and fan out:
strategy:
matrix:
phone: [PHONE_A, PHONE_B, PHONE_C]
Reference secrets[matrix.phone] to pull the right host per job. Now your suite runs across several real handsets in parallel, each on its own device, which is the kind of coverage an emulator farm can’t honestly give you.
why real devices in CI are worth it
The point of all this is trust in your pipeline. A passing run against an emulator tells you the app works on an emulator. A passing run against a real phone on a real mobile network tells you it works for an actual user. For anything that reads device signals or gets gated by region, that’s the difference between a meaningful test and a comforting one.
where cloudf.one fits
This setup needs a real Android device your runner can adb into over the network, which is what we run at cloudf.one. Real phones in Singapore on real SG mobile IPs, persistent so they’re there between CI runs, dedicated so two repos aren’t fighting over one handset. One honest caveat: adb from outside our network goes through a WireGuard tunnel scoped to your own phone, and that is invite-only for now, so message me before you build a pipeline on it. The complete workflow, tunnel up, lock the phone, connect, test, always release, is in our examples repo on GitHub. There’s a free trial on the cloudf.one home page if you want to wire a test job to one and watch it go green against real hardware. New accounts can use YT30 for a discount on the first month.
The takeaway: connect over network adb with a retry, store the host as a secret, always disconnect, and serialise device jobs with a concurrency group. Get those four right and a real phone is just another step in your pipeline.
Get new guides and videos first — join the Telegram channel.