I am running a very simple test:
public class BenchmarkAuto extends UiAutomatorTestCase {
public void testDemo() throws UiObjectNotFoundException {
getUiDevice().pressHome();
getUiDevice().click(650,461);
}
When I run it on an emulator it runs fine. When I run it on my Nexus 4 I get the following error (and my devices restarts):
java.lang.NullPointerException
at com.android.uiautomator.core.UiDevice.getDisplayWidth(UiDevice.java:379)
at com.android.uiautomator.core.UiDevice.click(UiDevice.java:407)
at org.zeroxlab.zeroxbenchmark.test.BenchmarkAuto.testDemo(BenchmarkAuto.java:29)
I looked at the UIDevice source code and it looks like this is the culprit:
Display display = getAutomatorBridge().getDefaultDisplay();
The display is null and causes the NullPointerException two lines later.
Anyone have any idea how to resolve this?