Question

I am getting below exection when running viewclient. I am running this on Emulator using 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.

Looking at the uiautomatorxml, by adding a print statement as below:

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

I got,

DEBUG: (XML file starts in a normal fashion, below is tail end of the log that was printed)

<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] Script terminated due to an exception

Clearly, XML is not fully formed. I was wondering if you had any ideas on why this could be happening and how to resolve this.

Was it helpful?

Solution 2

For me this was linked to performance of the machine where I was running emulator. I was able to resolve this issue by enabling hardware acceleration and having a machine with 1GB graphics card.

Steps for enabling hardware acceleration:

  • Check "use host gpu" in simulator.
  • Download and install Intel HAXM.

OTHER TIPS

I guess its because UIAutomation return contents is too long.Because I got the same message with you,but when I tern to one little view page and run and I fount that ViewClient is work well .. so I guess is something wrong with the sockets message didn't end with the complete oparate...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top