The UiAutomator2 instrumentation process may crash when the automation session becomes unstable or when the Appium session is not cleaned up correctly.
Common causes include:
Stale or orphaned Appium sessions
Improper session cleanup after test completion or failure
Reusing the same
systemPortacross multiple Android sessionsRunning long sequential test suites on the same device
Low UiAutomator2 launch timeout values
Aggressive back-to-back executions without allowing the device to recover
To reduce UiAutomator2 instrumentation crashes, follow these best practices:
Use a unique
systemPortAssign a unique
systemPortfor each Android session, especially during parallel execution.
Increase UiAutomator2 launch timeout
Increase
uiautomator2ServerLaunchTimeoutto allow more time for the UiAutomator2 server to start.
Always clean up the session
Ensure
driver.quit()is called at the end of every test, including failed executions.
Release the device if cleanup fails
If the session does not terminate properly, release the device from the platform before starting a new run.
Split long test suites
Break long sequential executions into smaller batches to reduce device and automation service instability.
Avoid immediate back-to-back execution on the same device
Allow a short recovery gap between executions, especially after failed or force-stopped session
If the issue continues, share the Appium logs, device name, Android version, capabilities used, execution timestamp, and the affected test case details with TestGrid Support.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article