dtmilano / AndroidViewClient

Android ViewServer and ADB client
Apache License 2.0
1.61k stars 344 forks source link

ValueError: received does not contain valid XML: Killed #307

Closed g123k closed 1 year ago

g123k commented 2 years ago

Hello,

When I try to dump the view hierarchy I have the following error. Any idea on how to fix it?

➜  ~ dump -x
Traceback (most recent call last):
  File "/Users/g123k/.pyenv/versions/3.10.4/lib/python3.10/site-packages/com/dtmilano/android/viewclient.py", line 3392, in __parseTreeFromUiAutomatorDump
    start_xml_index = receivedXml.index("<?xml")
ValueError: substring not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/g123k/.pyenv/versions/3.10.4/bin/dump", line 221, in <module>
    vc.dump(window=options[WINDOW])
  File "/Users/g123k/.pyenv/versions/3.10.4/lib/python3.10/site-packages/com/dtmilano/android/viewclient.py", line 3596, in dump
    self.setViewsFromUiAutomatorDump(received)
  File "/Users/g123k/.pyenv/versions/3.10.4/lib/python3.10/site-packages/com/dtmilano/android/viewclient.py", line 3178, in setViewsFromUiAutomatorDump
    self.__parseTreeFromUiAutomatorDump(received)
  File "/Users/g123k/.pyenv/versions/3.10.4/lib/python3.10/site-packages/com/dtmilano/android/viewclient.py", line 3395, in __parseTreeFromUiAutomatorDump
    raise ValueError("received does not contain valid XML: " + receivedXml)
ValueError: received does not contain valid XML: Killed
dtmilano commented 2 years ago

It's due to a problem with uiautomator dump, which is producing and empty response (that's why <?xml is not found). You can try to manually invoke uiautomator dump in your situation to analyze the response, whether it's empty or an error message.

Using a different backend for AndroidViewClient would help. You can try https://github.com/dtmilano/CulebraTester2-public which works in many cases where uiautomator does not.

sooraj-sizon-pj commented 10 months ago

Hi @dtmilano , I receive same error running AndroidViewClient on AWS ec2 instance Screenshot from 2023-10-31 13-07-36 I could not find uiautomatorin android sdk instead had to run uiautomatorviewer dump

Xlib extension RANDR missing on display :1

Do you know what might cause this issue ?

dtmilano commented 10 months ago

@sooraj-sizon-pj you didn't describe what you are trying to achieve and how? what devices do you have connected to the EC2 instance and how? what's the output of adb devices ?

dtmilano commented 10 months ago

The error shows the XML output was null.

sooraj-sizon-pj commented 10 months ago

@sooraj-sizon-pj you didn't describe what you are trying to achieve and how? what devices do you have connected to the EC2 instance and how? what's the output of adb devices ?

Device is custom android emulator x86_64 running on AWS EC2 , I have same Emulator setup on my local env where AndroidViewClient works perfectly Where as on EC2 with same Automation script it goes through a few screens of android setupwizard and able to click on buttons and views and fails with this crash on like 4th or 5th step .

The emulator is running custom system-images build from AOSP A11_r1 tag has custom setup wizard another system app and a system service running very early at boot.

dtmilano commented 10 months ago

@sooraj-sizon-pj please create another issue so we can track it properly. It's not exactly related to this one as several of the conditions are different.

sooraj-sizon-pj commented 10 months ago

@sooraj-sizon-pj please create another issue so we can track it properly. It's not exactly related to this one as several of the conditions are different.

+1 created a new issue https://github.com/dtmilano/AndroidViewClient/issues/320