adbutils icon indicating copy to clipboard operation
adbutils copied to clipboard

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

Open yinkh opened this issue 1 year ago • 3 comments

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

yinkh avatar May 31 '24 07:05 yinkh

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

harveyxie22 avatar Sep 09 '24 11:09 harveyxie22

@codeskyblue Hi guys, 我也发现了这个问题:在ubuntu环境下用2.6.0以上的版本执行shell会弹"unknown host service"的问题,降级到2.5.0没问题,但由于check_okey方法涉及到的地方有点多,能麻烦您看下吗 image diff: image

pinnnkman avatar Oct 12 '24 03:10 pinnnkman

I'm experiencing the same issue using adbutils==2.8.0

Traceback (most recent call last):
  File "/home/automation/rabbit/tests/robot/os/linux/serial_secure_boot/test_serial_secure_boot.py", line 266, in test_adb_shell_tryout
    d.shell('echo "Device is alive"')
  File "/home/automation/rabbit/venv/lib/python3.8/site-packages/adbutils/_device.py", line 191, in shell
    c = self.open_transport(timeout=timeout)
  File "/home/automation/rabbit/venv/lib/python3.8/site-packages/adbutils/_device.py", line 89, in open_transport
    c.check_okay()
  File "/home/automation/rabbit/venv/lib/python3.8/site-packages/adbutils/_adb.py", line 151, in check_okay
    raise AdbError(self.read_string_block())
adbutils.errors.AdbError: unknown host service

Ignaciopetru avatar Oct 16 '24 17:10 Ignaciopetru

update adb version to 1.0.41 or use adbutils==2.5.0

crazy-1677 avatar Dec 02 '24 09:12 crazy-1677

fixed in 2.9.2

codeskyblue avatar Jun 04 '25 02:06 codeskyblue