question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UiAutomator findObject is throwing IllegalStateException: UiAutomation not connected!

See original GitHub issue

Getting below Exception for every consecutive execution

java.lang.IllegalStateException: UiAutomation not connected!
at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:971)
at android.app.UiAutomation.waitForIdle(UiAutomation.java:577)
at android.support.test.uiautomator.UiAutomatorBridge.waitForIdle(UiAutomatorBridge.java:112)
at android.support.test.uiautomator.UiDevice.waitForIdle(UiDevice.java:639)
at android.support.test.uiautomator.UiDevice.waitForIdle(UiDevice.java:629)
at android.support.test.uiautomator.UiDevice.getWindowRoots(UiDevice.java:1074)
at android.support.test.uiautomator.UiDevice.findObject(UiDevice.java:164)

observed throwing above exception immediately after executing below statement in logcat

W WindowManager: Attempted to remove non-existing token: android.os.Binder@2728fc2

Tested on API Level: 19, 21, 23 emulators, issue also replicating in real device Uiautomator Version: com.android.support.test.uiautomator:uiautomator-v18:2.1.2

Please let me know if you need any other information.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:8
  • Comments:26 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
bootstraponlinecommented, Apr 19, 2016

Why is there no way for UiAutomation to automatically reconnect on disconnect?

8reactions
snijsurecommented, Dec 19, 2017

I am also getting same issue, when running robo tests on Firebase Cloud test infrastructure.

Fatal Exception: java.lang.IllegalStateException: UiAutomation not connected!
       at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1034)
       at android.app.UiAutomation.disconnect(UiAutomation.java:275)
       at android.app.Instrumentation.finish(Instrumentation.java:210)
       at android.support.test.runner.MonitoringInstrumentation.finish(MonitoringInstrumentation.java:351)
       at android.support.test.runner.AndroidJUnitRunner.finish(AndroidJUnitRunner.java:405)
       at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:394)
       at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Fabric: UiAutomation not connected - Stack Overflow
In this case the Google crawler goes in timeout and raises an exception. My advice is: be sure to not block UI with...
Read more >
UiAutomator findObject is throwing IllegalStateException
Getting below Exception for every consecutive execution java.lang.IllegalStateException: UiAutomation not connected! at android.app.
Read more >
java.lang.IllegalStateException: UiAutomation not connected!
I have Xamarin.Forms app in Google Play, I have brand new issue in pre-lunch report since I updated to the latest xamarin.forms and...
Read more >
android.support.test.uiautomator.UiDevice.findObject java ...
private void openActivity() throws UiObjectNotFoundException { device.pressHome(); UiObject allAppsButton= device.findObject(new ...
Read more >
Source Code for UiDevice.java - AndroidX Tech
package androidx.test.uiautomator; import android.accessibilityservice. ... throw new IllegalStateException("UiDevice singleton not initialized"); } return ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found