Android Emulator Driver¶
jumpstarter-driver-androidemulator manages Android emulator lifecycle with
ADB tunneling through Jumpstarter. It provides power control (start/stop) for
the Android emulator and combines it with the ADB driver for device access.
Installation¶
pip3 install --extra-index-url https://pkg.jumpstarter.dev/simple/ jumpstarter-driver-androidemulator
For the optional Python ADB API:
pip3 install --extra-index-url https://pkg.jumpstarter.dev/simple/ "jumpstarter-driver-androidemulator[python-api]"
Prerequisites¶
Android SDK with emulator and platform-tools installed
emulatorandadbavailable on PATH (or specifyemulator_path)An AVD created via Android Studio or
avdmanager
Quick AVD Setup¶
# Apple Silicon (arm64)
sdkmanager "system-images;android-35;google_apis;arm64-v8a"
avdmanager create avd -n Pixel_6 -k "system-images;android-35;google_apis;arm64-v8a" -d pixel_6
# Intel/AMD (x86_64)
sdkmanager "system-images;android-35;google_apis;x86_64"
avdmanager create avd -n Pixel_6 -k "system-images;android-35;google_apis;x86_64" -d pixel_6
Configuration¶
Example exporter configuration:
export:
android:
type: jumpstarter_driver_androidemulator.driver.AndroidEmulator
config:
avd_name: "Pixel_6"
headless: true
console_port: 5554
adb_server_port: 15037
Configuration Parameters¶
Parameter |
Description |
Type |
Required |
Default |
|---|---|---|---|---|
avd_name |
Name of the Android Virtual Device |
str |
yes |
|
emulator_path |
Path to the emulator executable |
str |
no |
“emulator” |
headless |
Run without a window |
bool |
no |
true |
console_port |
Emulator console port |
int |
no |
5554 |
adb_server_port |
Port for the custom ADB server |
int |
no |
15037 |
appium |
Run Appium on the exporter; see Appium |
dict |
no |
Usage¶
CLI¶
# Power on the emulator
j android power on
# Check ADB devices through the tunnel
j android adb devices
# Run ADB commands
j android adb shell getprop ro.product.model
# Create a persistent ADB tunnel
j android adb tunnel
# Power off the emulator
j android power off
Python API¶
from jumpstarter.common.utils import serve
from jumpstarter_driver_androidemulator.driver import AndroidEmulator
driver = AndroidEmulator(avd_name="Pixel_6")
with serve(driver) as client:
client.power.on()
# Wait for boot and get an adbutils device
with client.adb_device(timeout=180) as device:
print(device.prop.model)
print(device.shell("pm list packages"))
client.power.off()
Appium¶
With an appium block, the exporter runs Appium
with its UiAutomator2 driver for the emulator, and clients use the shared
Appium client, the same interface every UI-automation target
provides. The
UI automation guide
explains why Jumpstarter uses Appium and how to set it up. Enable it in the
emulator’s config:
config:
avd_name: "Pixel_6"
appium:
executable: /opt/appium/node_modules/.bin/appium
home: /opt/appium/home
from appium import webdriver
from appium.options.android import UiAutomator2Options
from jumpstarter.common.utils import serve
from jumpstarter_driver_androidemulator.driver import AndroidEmulator
driver = AndroidEmulator(avd_name="Pixel_6", appium={"home": "/opt/appium/home"})
with serve(driver) as client:
client.power.on()
with client.appium.serve() as target:
options = UiAutomator2Options().load_capabilities(target.capabilities())
session = webdriver.Remote(target.url, options=options, client_config=target.client_config())
try:
print(session.page_source)
finally:
session.quit()
client.power.off()
Power the emulator on first; Appium waits for it to finish booting. Sessions are
pinned to emulator-<console_port> on the emulator’s private ADB server, Appium
never kills that server, and power off stops Appium. j android appium prints
the endpoint. See ADB Driver for the capabilities Android targets reject.
Architecture¶
This is a composite driver with two children:
adb(AdbServerfromjumpstarter-driver-adb): Manages the ADB server and provides TCP tunneling for remote ADB accesspower(AndroidEmulatorPower): Controls the emulator process lifecycle via the standardPowerInterface(on/off/read)
The emulator registers with the custom ADB server on port 15037 (via the
ANDROID_ADB_SERVER_PORT environment variable) to avoid conflicts with any
local ADB server on the standard port 5037.
API Reference¶
Driver¶
- class jumpstarter_driver_androidemulator.driver.AndroidEmulator¶
Android emulator composite driver.
Manages an Android emulator with ADB tunneling. Children: -
adb: ADB server for device communication -power: Emulator lifecycle (on/off)- classmethod client() str¶
Return full import path of the corresponding driver client class
- driver_type: ClassVar[str] = 'composite'¶
Driver category for observability (e.g. power, storage, network, serial, console, video, composite).
- set_headless(headless: bool) None¶
Set headless mode. Must be called before power on.
- class jumpstarter_driver_androidemulator.driver.AndroidEmulatorPower¶
Power driver for Android emulator lifecycle management.
Starts the emulator with a minimal command line and shuts it down gracefully via
adb emu kill, falling back to process kill.- off() None¶
Stop the Android emulator.
- on() None¶
Start the Android emulator.
- async read() AsyncGenerator[PowerReading, None]¶
Return dummy power readings (emulator has no real power metrics).
Client¶
- class jumpstarter_driver_androidemulator.client.AndroidEmulatorClient¶
Client for Android emulator with ADB access.
Children: -
adb: ADB client for device communication -power: Power client for emulator lifecycle- adb_device(timeout: int = 180)¶
Forward ADB, wait for boot, and yield an adbutils device.
Requires the
python-apiextra (adbutils).- Args:
timeout: Seconds to wait for the emulator to finish booting.
- Yields:
An
adbutils.AdbDeviceconnected through the tunnel.