Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yinkh opened this issue May 31, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@yinkh
Copy link
Contributor

yinkh commented May 31, 2024

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
Copy link

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

@pinnnkman
Copy link
Contributor

pinnnkman commented Oct 12, 2024

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

@Ignaciopetru
Copy link

Ignaciopetru commented Oct 16, 2024

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

@codeskyblue codeskyblue added the bug Something isn't working label Oct 31, 2024
@crazy-1677
Copy link

update adb version to 1.0.41
or
use adbutils==2.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants