0

I found that "upgrading" my reference to UIAutomator in build.gradle to 2.1.2 broke any references I had to the UiDevice class. In fact, a lot seems to have changed but I'm finding nothing explaining it.

Can anyone shed some light on what is (apparently) about to change?

This works:

androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'

This does not:

androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'

Dependencies from build.gradle follow (made a mess of by trying to figure this out):

testCompile 'junit:junit:4.12'
// Optional -- Mockito framework
testCompile 'org.mockito:mockito-core:1.10.19'

androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.0', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

// Optional -- UI testing with UI Automator
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
androidTestCompile 'com.android.support:support-annotations:26.0.0'
androidTestCompile 'com.android.support.test:runner:1.0.0'
androidTestCompile 'com.android.support.test:rules:1.0.0'
// Optional -- Hamcrest library
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'

// Optional -- UI testing with Espresso
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support:design:26.0.0'
compile 'com.android.support:support-v4:26.0.0'
JoeHz
  • 2,136
  • 1
  • 18
  • 29
  • 1
    I got exactly that version and I can see android.support.test.uiautomator.UiDevice inside it. Try doing clean build and re-import the project in IDE if you use one. – Devstr Aug 14 '17 at 15:23
  • I've just confirmed it's really truly missing when I go back to 2.1.1. Even some JUnit stuff goes away too. I'm minSdkVersion 22 and targetSdkVersion 26. Going to go update this post with the dependencies section of my build.gradle – JoeHz Aug 14 '17 at 23:34
  • The JUnit problem was trying to downgrade runner and rules to 0.5. 1.0.0 fixed that but UiDevice is still missing (as is "By" as well. Seemingly anything in the uiautomator namespace) – JoeHz Aug 14 '17 at 23:45
  • Can you look at the contents of the actual jar in the gradle cache? Is the class present in there? If not, try cleaning the cache and rebuilding. – Devstr Aug 15 '17 at 06:53
  • In your dependencies, what is inside the 'libs' directory? Could there be another version of uiautomator in there? – Devstr Aug 15 '17 at 06:56
  • In Project Structure I found it claiming that uiautomator:2.1.2 had broken paths:  C:\Users\Joe\IdeaProjects\BidzClient\app\build\intermediates\exploded-aar\com.android.support.test.uiautomator\uiautomator-v18\2.1.2\jars\classes.jar   C:\Users\Joe\IdeaProjects\BidzClient\app\build\intermediates\exploded-aar\com.android.support.test.uiautomator\uiautomator-v18\2.1.2\res [Fix] – JoeHz Aug 17 '17 at 04:56
  • The Fix button removed the root declarations but did not resolve the problem. – JoeHz Aug 17 '17 at 04:58
  • But then I was able to Sync Gradle and that did it... Go figger. – JoeHz Aug 17 '17 at 05:03

0 Answers0