最近在学习monkeyrunner,想用MonkeyRecorder获取APP控件坐标(连接真机),但启动MonkeyRecorder后报错且显示空白(见截图),有人知道什么原因吗?
《MonkeyRecorder.py》代码如下:
from com.android.monkeyrunner import MonkeyRunner as mr
from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder
device = mr.waitForConnection(1,'设备号')
recorder.start(device)
报错信息(第一部分,第二部分在楼下):
E:\sdk>monkeyrunner G:\AutoTest\MonkeyRecorder.py
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] Unable to take snapshot
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce]com.android.ddmlib.TimeoutException
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at com.android.ddmlib.AdbHelper.read(AdbHelper.java:686)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at com.android.ddmlib.AdbHelper.read(AdbHelper.java:654)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at com.android.ddmlib.AdbHelper.getFrameBuffer(AdbHelper.java:327)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at com.android.ddmlib.Device.getScreenshot(Device.java:558)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at com.android.chimpchat.adb.AdbChimpDevice.takeSnapshot(AdbChimpDevice.
java:209)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at com.android.monkeyrunner.recorder.MonkeyRecorderFrame.refreshDisplay(
MonkeyRecorderFrame.java:115)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at com.android.monkeyrunner.recorder.MonkeyRecorderFrame.access$000(Monk
eyRecorderFrame.java:60)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at com.android.monkeyrunner.recorder.MonkeyRecorderFrame$2.run(MonkeyRec
orderFrame.java:109)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventQueue.access$200(EventQueue.java:103)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventQueue$3.run(EventQueue.java:682)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventQueue$3.run(EventQueue.java:680)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.security.AccessController.doPrivileged(Native Method)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:242)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:161)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
161020 14:46:14.792:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.android.monkeyrunner.recorder.MonkeyRecorderFrame.refreshDisplay(
MonkeyRecorderFrame.java:116)
at com.android.monkeyrunner.recorder.MonkeyRecorderFrame.access$000(Monk
eyRecorderFrame.java:60)
at com.android.monkeyrunner.recorder.MonkeyRecorderFrame$2.run(MonkeyRec
orderFrame.java:109)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
报错信息第二部分:
161020 14:46:19.863:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
161020 14:46:19.863:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:242)
161020 14:46:19.863:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:161)
161020 14:46:19.863:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
161020 14:46:19.863:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
161020 14:46:19.863:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
161020 14:46:19.863:S [AWT-EventQueue-0] [com.android.chimpchat.adb.AdbChimpDevi
ce] at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.android.monkeyrunner.recorder.MonkeyRecorderFrame.refreshDisplay(
MonkeyRecorderFrame.java:116)
at com.android.monkeyrunner.recorder.MonkeyRecorderFrame.access$000(Monk
eyRecorderFrame.java:60)
at com.android.monkeyrunner.recorder.MonkeyRecorderFrame$1.actionPerform
ed(MonkeyRecorderFrame.java:89)
at javax.swing.Timer.fireActionPerformed(Timer.java:312)
at javax.swing.Timer$DoPostEvent.run(Timer.java:244)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDo
main.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)