dtmilano / AndroidViewClient

Android ViewServer and ADB client
Apache License 2.0
1.62k stars 345 forks source link

takeSnapshot ERROR #268

Closed uohoo closed 5 years ago

uohoo commented 5 years ago

When I try to use the functionality takeSnapshot, it seems that the socket is closed, I get the following error. I'm using BlueStacks emulator and is detecting the device correctly. When trying the other method, the alternative to USE_ADB_FRAMEBUFFER_METHOD, it shows the same behaviour.

Exception has occurred: RuntimeError
ERROR: b'FAIL' b'0006closed'
  File "C:\Program Files\Python37\Lib\site-packages\androidviewclient3\adb\adbclient.py", line 350, in __checkOk
    raise RuntimeError("ERROR: %s %s" % (repr(recv), error))
  File "C:\Program Files\Python37\Lib\site-packages\androidviewclient3\adb\adbclient.py", line 289, in __send
    self.__checkOk()
  File "C:\Program Files\Python37\Lib\site-packages\androidviewclient3\adb\adbclient.py", line 778, in takeSnapshot
    self.__send('framebuffer:', checkok=True, reconnect=False)
dtmilano commented 5 years ago

You should use python 2.7.

uohoo commented 5 years ago

Thank you for your quick respond. I tried with other emulators and physical devices using python3 and the code works properly. Any idea what this problem could be related with? Could be that sending the string 'framebuffer:' using python3 has a different behaviour that causes the error close? self.__send('framebuffer:', checkok=True, reconnect=False)

uohoo commented 5 years ago

I was trying to find the problem and got this error message when executing the next line. I forced using the not FRAMEBUFFER method (BlueStacks uses the 25 sdk version which normally uses the FRAMEBUFFER method) but I guess that the same problem occurs when using FRAMEBUFFER. self.shell('/system/bin/screencap -p', False).replace(b'\r\n', b'\n')

ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
shell(_cmd=/system/bin/screencap -p)
__checkTransport()
__send(shell:/system/bin/screencap -p, checkok=True, reconnect=False)
Canceling timer with ID=70
__checkOk()
checkConnected()
    checkConnected: returning True
Canceling timer with ID=71
    __checkOk: recv= b'FAIL'
Canceling timer with ID=72
shell(_cmd=/system/bin/screencap -p)
__checkTransport()
__send(shell:/system/bin/screencap -p, checkok=True, reconnect=False)
Canceling timer with ID=73
__checkOk()
checkConnected()
    checkConnected: returning True
Canceling timer with ID=74
uohoo commented 5 years ago

I found the problem, BS was blocking connection because adb was disabled. I just had to enable Adb on BlueStacks options.