Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android UiAutomator在Nexus4上崩溃,但在emulator上工作正常_Android_Nullpointerexception_Android Uiautomator_Nexus 4 - Fatal编程技术网

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();