我在使用Instrumentation的各種android設備上運行我的單元測試。除了Samsung Galaxy S之外,所有設備上的仿真器&都能正常工作。關於在Samsung Galaxy S上調度'Down'鍵的「窗口管理器崩潰」
D/dalvikvm(11862): GC_EXPLICIT freed 6800 objects/374040 bytes in 54ms
D/dalvikvm(11862): GC_EXPLICIT freed 780 objects/71856 bytes in 39ms
W/dalvikvm(11862): threadid=9: thread exiting with uncaught exception (group=0x4001d7d0)
E/WindowManager(2472): Window Manager Crash
E/WindowManager(2472): java.lang.NullPointerException
E/WindowManager(2472): at com.android.server.WindowManagerService$KeyWaiter.waitForNextEventTarget(WindowManagerService.java:5844)
E/WindowManager(2472): at com.android.server.WindowManagerService.injectKeyEvent(WindowManagerService.java:5565)
E/WindowManager(2472): at android.view.IWindowManager$Stub.onTransact(IWindowManager.java:110)
E/WindowManager(2472): at com.android.server.WindowManagerService.onTransact(WindowManagerService.java:692)
E/WindowManager(2472): at android.os.Binder.execTransact(Binder.java:288)
E/WindowManager(2472): at dalvik.system.NativeStart.run(Native Method)
E/AndroidRuntime(11862): FATAL EXCEPTION: Instr: com.myapp.test.ImpInstrumentation
E/AndroidRuntime(11862): java.lang.NullPointerException
E/AndroidRuntime(11862): at android.os.Parcel.readException(Parcel.java:1266)
E/AndroidRuntime(11862): at android.os.Parcel.readException(Parcel.java:1248)
E/AndroidRuntime(11862): at android.view.IWindowManager$Stub$Proxy.injectKeyEvent(IWindowManager.java:830)
E/AndroidRuntime(11862): at android.app.Instrumentation.sendKeySync(Instrumentation.java:859)
E/AndroidRuntime(11862): at android.app.Instrumentation.sendKeyDownUpSync(Instrumentation.java:872)
E/AndroidRuntime(11862): at com.myapp.test.util.ListUtil.<b>arrowDownToPosition</b>(ListUtil.java:69)
這裏是一段代碼,它通常會崩潰:
在三星Galaxy S是使用儀器下面是完整的崩潰日誌注入一些30關鍵事件後顯示 窗口管理器崩潰private void arrowDownToPosition(int position) {
int maxDowns = 50;
while(mListView.getSelectedItemPosition() < position && --maxDowns > 0) {
mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN);
}
//Crashes on below line dispatching enter key
mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_ENTER);
}
歡迎提供所有解決方案/建議。
什麼版本的Android? – 2012-02-03 10:56:38
Android 2.2上的@ReubenScratton – 100rabh 2012-02-03 12:29:16
煩惱你的堆棧跟蹤與2.2.x源代碼樹不一致。據推測三星定製它。 – 2012-02-03 13:20:38