📚 Encyclopedia

Android · updated 2026-11-30

Driving the Android emulator headlessly for QA

androidemulatoradbuiautomatorqatestingavd

Headless ProcrastinAI sessions test Android apps on an emulator with no screen and no human: boot an AVD without a window, install the release APK, drive it with adb, read results from logcat, screenshots and uiautomator dumps. On the desktop the main AVD is msg35 (API 35). This is what made that reliable.

Booting

Input methods

Driving the UI

Environment limits

Test-data hygiene

An "autocorrect then backspace" test teaches the keyboard the typo, and that survives in app data, so a later run looks like autocorrect broke. Compare on a clean install. Restore emulator settings and IME when done. The same goes for roles: a dialer or SMS app under test takes the default role, so give it back afterward (cmd role add-role-holder android.app.role.DIALER com.google.android.dialer).

Testing behind a screen lock. Code paths gated on the device credential (BiometricPrompt, keyguard checks) never run on an emulator with no lock, so bugs there ship unseen. Set one for the test and remove it after: adb shell locksettings set-pin 1234, then adb shell locksettings clear --old 1234. The system lock prompt is a secure window, so screencap returns black while it shows; confirm it by name with dumpsys window | grep mCurrentFocus. Check that focus before adb shell input text 1234 too: with no prompt on screen the digits go to whatever is in front (the launcher opened a calendar app).

Serving a test page to the emulator. Run python3 -m http.server PORT on the desktop and adb reverse tcp:PORT tcp:PORT, then open http://localhost:PORT/ in the app. localhost counts as a secure context, so features that need HTTPS (card autofill, clipboard, service workers) work without putting a test form on a public site.

Bound the boot wait. An AVD sometimes never finishes booting (no system_server, adb shell hangs). A script that waits on boot in an open-ended loop eats the whole time budget of an automated run; start the emulator first, wait with a deadline, and fall back to another AVD or -no-snapshot-load.

Kill the emulator when the test is done (adb emu kill). One left running for five days after an app test, with -gpu swiftshader_indirect (software rendering), burned about 8 desktop cores redrawing an idle screen: load 10.5, fans near 4000 RPM (tldr post #1862, see VictusPop, Justin's desktop (hardware, OS, boot, quirks)). Its saved state survives the kill.

See also

Linked from

Sources: plumb memory (plumb-android-app), keyboard memory (history, posts #1715 to #1751), message memory (startup_perf_2026_09), tokay notes in home memory, map/phone/files memory (2026-10), tldr post #1862, tokay memory (0.3.9, 0.3.10), swerve memory (swerve-testing), 2026-11-25