Appium capabilities for Android
The UiAutomator2 capabilities that matter for Android, what SpawnDroid fills in, and working Java, Python, Kotlin and WebdriverIO examples.
Capabilities tell Appium which device to use and which app to drive. On
SpawnDroid the build is already installed on the session device, so the
capability set is smaller than a local Appium setup: there is no appium:app
and no emulator to start.
The minimum set
| Capability | Value | Why |
|---|---|---|
platformName | Android | Selects the Android driver. |
appium:automationName | UiAutomator2 | Required by Appium 3; SpawnDroid runs UiAutomator2 8.x. |
appium:udid | device.serial from the session response | Targets this session's device. |
appium:appPackage | app.package from the session response | The build is installed; this is what to launch. |
appium:autoGrantPermissions | true | Avoids a permission dialog blocking the first test. |
Do not set appium:app. The build is already installed on the session
device. Setting it makes Appium install the APK again and can fail when the
session's storage URL is not reachable from the device.
Optional capabilities
| Capability | Use it when |
|---|---|
appium:appActivity | The app has more than one launcher activity and you need a specific one. |
appium:appWaitActivity | The splash activity differs from the main activity. |
appium:noReset | You want app data preserved between sessions. Not the default here: each session starts from a clean device. |
appium:newCommandTimeout | Your suite waits on a long operation and the default command timeout is too short. |
appium:language, appium:locale | You need a specific device language. Prefer the session config.locale so the device boots in the right language. |
appium:orientation | The test needs a fixed orientation. Prefer the session config.orientation when starting. |
Working Java example
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("platformName", "Android");
caps.setCapability("appium:automationName", "UiAutomator2");
caps.setCapability("appium:udid", System.getenv("SPAWNDROID_UDID"));
caps.setCapability("appium:appPackage", System.getenv("SPAWNDROID_APP_PACKAGE"));
caps.setCapability("appium:autoGrantPermissions", true);
AndroidDriver driver = new AndroidDriver(
new URL(System.getenv("SPAWNDROID_WD_URL")), caps);
driver.quit();Working Python example
import os
from appium import webdriver
from appium.options.android import UiAutomator2Options
options = UiAutomator2Options().load_capabilities({
"platformName": "Android",
"appium:automationName": "UiAutomator2",
"appium:udid": os.environ["SPAWNDROID_UDID"],
"appium:appPackage": os.environ["SPAWNDROID_APP_PACKAGE"],
"appium:autoGrantPermissions": True,
})
driver = webdriver.Remote(os.environ["SPAWNDROID_WD_URL"], options=options)
driver.quit()The same capability object works in Kotlin and WebdriverIO. See the Python, Java, Kotlin and WebdriverIO guides for complete suites.
Common errors
The application is not installed—appium:appPackagedoes not match the uploaded build. Readapp.packagefrom the session response.Session not found— theudidbelongs to a different session. Use thedevice.serialreturned by that session, not a remembered value.Could not find a driver for automationName— the capability is missing or misspelled. It isappium:automationName, notautomationName.- The app opens then closes — a launcher activity mismatch. Set
appium:appActivityfrom the APK manifest.
Generate the block
The capabilities generator builds the same block for Java, Kotlin, Python and WebdriverIO from the session's URL, serial and package. It runs in the browser.
Run it on SpawnDroid
Start a hosted runner, copy the WebDriver URL and device serial, and paste the capabilities above into your suite. The Hobby plan includes one runner and 200 device-minutes a month, no card. Start free or read CI tests for the full session flow.
Was this page helpful?