Android UiAutomator在Nexus4上崩溃,但在emulator上工作正常
我正在运行一个非常简单的测试:Android UiAutomator在Nexus4上崩溃,但在emulator上工作正常,android,nullpointerexception,android-uiautomator,nexus-4,Android,Nullpointerexception,Android Uiautomator,Nexus 4,我正在运行一个非常简单的测试: public class BenchmarkAuto extends UiAutomatorTestCase { public void testDemo() throws UiObjectNotFoundException { getUiDevice().pressHome(); getUiDevice().click(650,461); } 当我在模拟器上运行它时,它运行良好。当我在Nexu
public class BenchmarkAuto extends UiAutomatorTestCase {
public void testDemo() throws UiObjectNotFoundException {
getUiDevice().pressHome();
getUiDevice().click(650,461);
}
当我在模拟器上运行它时,它运行良好。当我在Nexus 4上运行它时,会出现以下错误(并且我的设备会重新启动):
我查看了UIDevice的源代码,看起来这就是罪魁祸首:
Display display = getAutomatorBridge().getDefaultDisplay();
显示为null,并在两行之后导致NullPointerException
有人知道如何解决这个问题吗?问题是我在开发者选项中打开了“指针位置”。关掉它,它就可以正常工作了。希望其他人也有同样的问题,这对他们有帮助:)你知道为什么“指针位置”会导致崩溃吗?不知道。但我不明白为什么在运行uiautomator时需要打开指针位置。
Display display = getAutomatorBridge().getDefaultDisplay();