Uiautomator2 - possible bug

Hey guys,

I just installed [email protected] in order to try uiautomator2 again (tried on 1.6.0 and had a lot of issues finding elements and so on, therefore, 1.6.1 is definitely performing better on this topic).

Now, on 1.6.1-beta, if I start 2 appium nodes (automationName=‘uiautomator2’) with different ports and different bootstrap ports, connect them to the selenium grid and start the test, everything works fine until the “finding elements” part. To be more specific, the test starts, the app is installed successfully and then launched, the first getAppium().findElement() is called without success.

If I run just one of the tests, everything is OK but as soon as I have another test started (on another device and another node) no elements can be found.

I apologize for not providing too much info, I had to revert to 1.6.0 so I can continue my work, if there is something needed in particular to help with this, please let me know and I will try to provide it in the following days. I was hoping that somebody is already aware of this.

@mkzr can you please file the issue under https://github.com/appium/appium/issues with code sample and appium logs ?


As there is no much info provided, assuming this could be system port number issue.


Try by setting the available port number in systemPort capability

capabilities.setCapability(“systemPort”, “8181”)

Hello everyone and thank you for replying, I really appreciate it!

I apologize for not posting earlier, I was busy.

@Sravanmedarapu - I tried your suggestion, does not work, same thing happens. Please see below for more details.

The one node that runs with uiAutomator2 is OK, the other ones stop after this step:

[debug] [UiAutomator] Starting UIAutomator
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s",“06c64cb3d007fd3d”,“shell”,“uiautomator”,“runtest”,“AppiumBootstrap.jar”,"-c",“io.appium.android.bootstrap.Bootstrap”,"-e",“pkg”,“com.xxx.dev”,"-e",“disableAndroidWatchers”,false,"-e",“acceptSslCerts”,false]
[UiAutomator] UiAutomator exited unexpectedly with code 0, signal null
[debug] [UiAutomator] Moving to state ‘stopped’

Please see below the output of the above command that fails:

adb -P 5037 -s 06c64cb3d007fd3d shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.xxx.dev -e disableAndroidWatchers false -e acceptSslCerts false

INSTRUMENTATION_RESULT: shortMsg=java.lang.IllegalStateException
INSTRUMENTATION_RESULT: longMsg=UiAutomationService android.accessibilityservice.IAccessibilityServiceClient$Stub$Proxy@25023f09already registered!

NOTE - tried on 1.6.1 not 1.6.1-beta.

Thanks again for your time.

@mkzr seems you have not closed the previous driver sessions. Can you please make sure you are deleting the sessions before creating new driver instances.

There is no previous session, happens in the first one, please see this gist

The only other session is the one on the other node that’s running uiautomator2.

Is this issue replicatable if you run on all nodes either in UiAutomator or UiAutomator2 ?

The above issue happens if I run X nodes with uiautomator1 and 1 node with uiautomator2. The nodes running with uiautomator1 just stop working. “[debug] [UiAutomator] Moving to state ‘stopped’” is the last message available on the uiautomator1 nodes, can’t get rid of it unless I close and restart the node.

While running 2 nodes with uiautomator2, the nodes do not give any fatal errors and stop working, however, no elements are found when running the test. Below is an example of 1 test run on one of these nodes:

Furthermore, every now and then, some of the following errors might appear on one of the nodes but nothing that would cause them to stop like the uiautomator1 from the above example:

https://gist.github.com/cdamian/2043848fd3d287fd717c06b9ef87f6cb (2 errors in 1 gist as I am unable to post a lot of links)

The last thing that I noticed is that, the moment one of the uiautomator2 nodes is stopped, the other one works as expected.

Can you please try with [email protected]

If it still replicating, Can you please share android device logs along with appium logs for investing the root cause.

Tried with [email protected] and [email protected] . Seems to work for now. I will get back to you if I have any issues related on this topic.

Thank you very much for your support and keep up the awesome work!