UIAutomator shutdown on locating element

Hi all,
I have a Java test which constantly passes on my local workstation and crashes on remote box due to UIAutomator failure.
Both boxes are Macs running Appium 1.6.3 installed via npm.

The test always crashes on remote box at the point when I try to locate a button which should (for a happy path) be clicked and disappear from DOM. I tried both findElement and findElements approach, and both resulted in the following:

…after several failed attempts to locate the element when no crashes happened:

2017-02-17 13:16:16:176 - [debug] [AndroidBootstrap] Received command result from bootstrap 2017-02-17 13:16:16:178 - [debug] [BaseDriver] Waited for 3475 ms so far 2017-02-17 13:16:16:682 - [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"action_popular","context":"","multiple":false}} 2017-02-17 13:16:16:703 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"action_popular","context":"","multiple":false}} 2017-02-17 13:16:16:703 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION 2017-02-17 13:16:16:704 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find 2017-02-17 13:16:16:705 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'action_popular' using 'ID' with the contextId: '' multiple: false 2017-02-17 13:16:16:705 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.******.******.******/action_popular] 2017-02-17 13:16:16:998 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=android:id/action_popular] 2017-02-17 13:16:17:031 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=action_popular] 2017-02-17 13:16:17:051 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[DESCRIPTION=action_popular, INSTANCE=0] 2017-02-17 13:16:17:146 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying. 2017-02-17 13:16:17:148 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'action_popular' using 'ID' with the contextId: '' multiple: false 2017-02-17 13:16:17:148 - [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.******.******.******:id/action_popular] 2017-02-17 13:16:17:266 - [UiAutomator] UiAutomator exited unexpectedly with code 0, signal null 2017-02-17 13:16:17:267 - [debug] [UiAutomator] Moving to state 'stopped' 2017-02-17 13:16:17:280 - [debug] [AndroidDriver] Shutting down Android driver 2017-02-17 13:16:17:281 - [Appium] Closing session, cause was 'UiAUtomator shut down unexpectedly' 2017-02-17 13:16:17:282 - [Appium] Removing session 3301f6f9-f5a3-4ab4-ad0c-ba3c7fdcb818 from our master session list 2017-02-17 13:16:17:284 - [debug] [ADB] Getting connected devices...

It never reproduces on my local box and always reproduces on remote one.
In both cases tests are executed against similarly configured emulators: it is an AVD of Nexus9 tablet with Android 6.0, API 23 on board. Tests are not executed in headless mode in either case.

I tried switching to UIAutomator2, but my tests started failing even on the earlier step with a weird issue:

java.lang.NullPointerException at io.appium.java_client.pagefactory.ThrowableUtil.extractReadableException(ThrowableUtil.java:57) at io.appium.java_client.pagefactory.ThrowableUtil.extractReadableException(ThrowableUtil.java:62) at io.appium.java_client.pagefactory.ThrowableUtil.extractReadableException(ThrowableUtil.java:62)

, so I switched back to UIAutomator.

Is there any additional data I can provide to help investigate this issue?

Hello I have the same problem, did you find something?

The issue is no longer reproduced for me on newer environment: Appium 1.6.5, Java client 5.0.1. If you aren’t running the latest Appium version, I would recommend updating, as now UIAutomator2 doesn’t throw this exception.