Guides

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

CapabilityValueWhy
platformNameAndroidSelects the Android driver.
appium:automationNameUiAutomator2Required by Appium 3; SpawnDroid runs UiAutomator2 8.x.
appium:udiddevice.serial from the session responseTargets this session's device.
appium:appPackageapp.package from the session responseThe build is installed; this is what to launch.
appium:autoGrantPermissionstrueAvoids 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

CapabilityUse it when
appium:appActivityThe app has more than one launcher activity and you need a specific one.
appium:appWaitActivityThe splash activity differs from the main activity.
appium:noResetYou want app data preserved between sessions. Not the default here: each session starts from a clean device.
appium:newCommandTimeoutYour suite waits on a long operation and the default command timeout is too short.
appium:language, appium:localeYou need a specific device language. Prefer the session config.locale so the device boots in the right language.
appium:orientationThe test needs a fixed orientation. Prefer the session config.orientation when starting.

Working Java example

CheckoutTest.java
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

test_caps.py
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:appPackage does not match the uploaded build. Read app.package from the session response.
  • Session not found — the udid belongs to a different session. Use the device.serial returned by that session, not a remembered value.
  • Could not find a driver for automationName — the capability is missing or misspelled. It is appium:automationName, not automationName.
  • The app opens then closes — a launcher activity mismatch. Set appium:appActivity from 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?

On this page