openatx / adbutils

pure python adb library for google adb service.
MIT License
781 stars 180 forks source link

Since 2.6.0, shell command with serial on ubuntu system will raise adbutils.errors.AdbError: unknown host service #130

Open yinkh opened 4 months ago

yinkh commented 4 months ago
import adbutils
import os
port = int(os.getenv('ANDROID_ADB_SERVER_PORT', 5037))
client = adbutils.AdbClient(host="127.0.0.1", port=port)
serial = '7aa358b3'
#device = client.device(serial)
device = client.device_list()[0]
package_list = device.list_packages()
print(package_list)

will get error:

Traceback (most recent call last):
  File "/home/opt//demo.py", line 8, in <module>
    package_list = device.list_packages()
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/opt//venv/lib/python3.11/site-packages/adbutils/shell.py", line 250, in list_packages
    output = self.shell(["pm", "list", "packages"])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/opt//venv/lib/python3.11/site-packages/adbutils/_device.py", line 192, in shell
    c = self.open_transport(timeout=timeout)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/opt//venv/lib/python3.11/site-packages/adbutils/_device.py", line 90, in open_transport
    c.check_okay()
  File "/home/opt//venv/lib/python3.11/site-packages/adbutils/_adb.py", line 147, in check_okay
    raise AdbError(self.read_string_block())
adbutils.errors.AdbError: unknown host service

downgrade to 2.5.0 is good. and same code and same adbutils on windows is good.

windows adb server version is Android Debug Bridge version 1.0.41 ubuntu adb server version is Android Debug Bridge version 1.0.39

image this code cause new bug

harveyxie22 commented 3 weeks ago

The same error happened to me in my local environment (Ubuntu 20.04). Please help us, thanks!