53

After deployment of an app to Google Play Beta I see next issue in Crashlytics (6 - 7 users are affected)

Fatal Exception: java.lang.IllegalStateException: UiAutomation not connected!
   at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:971)
   at android.app.UiAutomation.disconnect(UiAutomation.java:237)
   at android.app.Instrumentation.finish(Instrumentation.java:222)
   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:1960)

It seems that it's google test devices. Any ideas about fix?

Vitalii
  • 10,091
  • 18
  • 83
  • 151

4 Answers4

29

It seems like nothing to worry about (don't rely on accepted answer and don't remove your tests) because crashes have been reported on creating pre-launch report for google play store where some UI automation tests were executed. If you track devices on which this error has occurred then you'll see that all paths lead to pre-launch report.

You can find out more about pre-launch report here

ares
  • 494
  • 4
  • 10
7

It seems that this crash is related to UI testing in your app. If you don't have any UI testing and there are only default settings which added automatically during creating the project, you should remove from your build.gradle the line testInstrumentationRunner in defaultConfig

  defaultConfig {
   ....
   testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} 

and androidTestCompile, testCompile in dependencies

dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
    exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
...
E I
  • 501
  • 4
  • 13
  • 12
    what about if u have tests o.O :D – Jemshit Feb 12 '18 at 15:18
  • Indeed what if you do have tests? I'm not convinced this will occur to average users as in their case the instrumentation runner should not be invoked. I believe its confined to Google test devices, I would like confirmation on this though... – Martin Price Feb 15 '18 at 23:03
  • 1
    I removed those lines but still get that exception reported in production – Juan Cruz Soler Nov 02 '18 at 15:43
  • 2
    I don't have any of those lines in build.gradle, but I'm starting to see the issue. – 3c71 Feb 27 '19 at 14:16
1

One thing is sure: you have an issue on UI. In most cases this occurs when you show a progress dialog that keeps being displayed for too much time. In this case the Google crawler goes in timeout and raises an exception. My advice is: be sure to not block UI with infinite dialogs.

Mariusz Wiazowski
  • 2,118
  • 1
  • 16
  • 17
1

The funny thing is that I get this crash while my app is being tested by google before publishing. I really don't know what google team is doing.