0

运行 viewclient 时,我正在执行以下操作。我正在使用 android-17 api 在模拟器上运行它。

viewclient = ViewClient(device, serialno)
File "/Users/dpbuild/Jenkins/workspace/AndroidViewer-FeatureBranch-UIAutomation/siamang/src/dtmilano/android/viewclient.py", line 948, in __init__
self.dump()
File "/Users/dpbuild/Jenkins/workspace/AndroidViewer-FeatureBranch-UIAutomation/siamang/src/dtmilano/android/viewclient.py", line 1478, in dump
self.setViewsFromUiAutomatorDump(received)
File "/Users/dpbuild/Jenkins/workspace/AndroidViewer-FeatureBranch-UIAutomation/siamang/src/dtmilano/android/viewclient.py", line 1251, in setViewsFromUiAutomatorDump
self.__parseTreeFromUiAutomatorDump(received)
File "/Users/dpbuild/Jenkins/workspace/AndroidViewer-FeatureBranch-UIAutomation/siamang/src/dtmilano/android/viewclient.py", line 1405, in _ViewClient__parseTreeFromUiAutomatorDump
self.root = parser.Parse(receivedXml)
File "/Users/dpbuild/Jenkins/workspace/AndroidViewer-FeatureBranch-UIAutomation/siamang/src/dtmilano/android/viewclient.py", line 832, in Parse
parserStatus = parser.Parse(uiautomatorxml, 1) #@UnusedVariable
File "/Tools/android-sdk-macosx/tools/lib/jython.jar/Lib/xml/parsers/expat.py", line 212, in Parse
xml.parsers.expat.ExpatError: XML document structures must start and end within the same entity.

查看 uiautomatorxml,通过添加如下打印语句:

def Parse(self, uiautomatorxml):
# Create an Expat parser
parser = xml.parsers.expat.ParserCreate()
# Set the Expat event handlers to our methods
parser.StartElementHandler = self.StartElement
parser.EndElementHandler = self.EndElement
parser.CharacterDataHandler = self.CharacterData
# Parse the XML File
**print "DEBUG: " + uiautomatorxml**
parserStatus = parser.Parse(uiautomatorxml, 1) #@UnusedVariable
return self.root

我有,

调试:(XML 文件以正常方式开始,下面是打印的日志的尾部)

<node index="1" text="" class="android.view.View" package="com.android.launcher" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="true" long-clickable="false" password="false" selected="false" bounds="[0,25][800,1232]"><node index="2" text="" class="android.view.View" package="com.android.launcher" content-desc="Home screen 3" checkable="false" checked="false" clickable="true" enabled="true" focusable="false" focus

130515 19:41:07.014:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] 脚本因异常而终止

显然,XML 没有完全形成。我想知道您是否对为什么会发生这种情况以及如何解决这个问题有任何想法。

4

2 回答 2

0

我猜是因为 UIAutomation 返回的内容太长了。因为我和你得到了同样的信息,但是当我转到一个小视图页面并运行时,我发现 ViewClient 运行良好..所以我猜是套接字有问题消息并没有以完整的 oparate 结束...

于 2013-08-09T05:12:47.287 回答
0

对我来说,这与我运行模拟器的机器的性能有关。我能够通过启用硬件加速并拥有一台配备 1GB 显卡的机器来解决这个问题。

启用硬件加速的步骤:

  • 在模拟器中选中“使用主机 gpu”。
  • 下载并安装英特尔 HAXM。
于 2013-08-09T17:25:04.223 回答