2013-10-22 32 views
0

罰款,我運行一個非常簡單的測試:UiAutomator崩潰在Nexus 4,但工作在模擬器

public class BenchmarkAuto extends UiAutomatorTestCase { 
    public void testDemo() throws UiObjectNotFoundException { 
      getUiDevice().pressHome(); 
      getUiDevice().click(650,461); 
    } 

當我在模擬器上運行它,它運行良好。當我在我的Nexus 4運行它,我得到以下錯誤(和我的設備重新啓動):

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) 

我看着的UIDevice源代碼,它看起來這是罪魁禍首:

Display display = getAutomatorBridge().getDefaultDisplay(); 

顯示爲空,並在稍後兩行導致NullPointerException。

任何人有任何想法如何解決這個問題?

回答

1

問題是我在開發人員選項中打開了「指針位置」。關掉它,它工作得很好。希望別人有同樣的問題,這有助於他們:)

+0

你有什麼想法,爲什麼「指針位置」導致這次崩潰? – Rilwan

+0

不知道。但是我不明白爲什麼在運行uiautomator時需要指針位置。 –

相關問題