Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Old adb server version (31) is not supported using AdbDeviceTcp #183

@Noam5

Description

@Noam5

The following snippet crashes when trying to connect to the adb using tcp

from adb_shell.adb_device import AdbDeviceTcp
from adb_shell.auth.sign_pythonrsa import PythonRSASigner

adbkey = r'path/to/adbkey'

with open(adbkey) as f:
    priv = f.read()
with open(adbkey + '.pub') as f:
     pub = f.read()
signer = PythonRSASigner(pub, priv)

device1 = AdbDeviceTcp('127.0.0.1', 5553, default_transport_timeout_s=9.)
device1.connect(rsa_keys=[signer], auth_timeout_s=0.1)

And this is the traceback that I'm getting:

Traceback (most recent call last):
  File "c:\temp\adbtest.py", line 15, in <module>
    device1.connect(auth_timeout_s=0.1)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\adb_shell\adb_device.py", line 219, in connect
    cmd, arg0, arg1, banner = self._read([constants.AUTH, constants.CNXN], adb_info)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\adb_shell\adb_device.py", line 754, in _read
    cmd, arg0, arg1, data_length, data_checksum = unpack(msg)
  File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\adb_shell\adb_message.py", line 122, in unpack
    raise ValueError('Unable to unpack ADB command. (length={})'.format(len(message)), constants.MESSAGE_FORMAT, message, e)
ValueError: ('Unable to unpack ADB command. (length=0)', b'<6I', b'', error('unpack requires a buffer of 24 bytes'))

When connecting through my adb client, I'm given the following error message:

adb server version (31) doesn't match this client (41); killing...

When testing the connection to an updated server (My 10 android phone) it all worked fine (Tested using the mentioned snippet and also an adb.exe client)
Which makes me think that the problem is caused by an unsupported old version of the server.
Given I cannot update the server adb version, how can I make the code compatible with the old version server?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions