简体   繁体   English

为什么Uiautomator在getUiDevices()中崩溃?

[英]why Uiautomator crashes in getUiDevices()?

i am trying to write a testing tool: create a thread in MainActivity and call Uiautomator functions to scan and analyze the UI components. 我正在尝试编写一个测试工具:在MainActivity中创建一个线程,并调用Uiautomator函数来扫描和分析UI组件。 is that possible? 那可能吗? why it always crashes in getUiDevice()? 为什么总是在getUiDevice()中崩溃? thanks! 谢谢!

First of all, UiAutomatorTestCase is deprecated and you should use UiDevice.getInstance() . 首先, UiAutomatorTestCase 废弃 ,你应该使用UiDevice.getInstance() 。

Getting the UiDevice requires an Instrumentation instance that cannot be obtained from the same Activity, that's why you need to do it from a test run from adb . 获取UiDevice需要无法从同一Activity中获得的Instrumentation实例,这就是为什么需要通过adb进行的测试来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM