uiautomator2
uiautomator2 copied to clipboard
Cant connect to devices
THIS IS MYCODE ------------------------ import uiautomator2 d = uiautomator2.connect("127.0.0.1:5555")
INFORMATION MOBILE -------------------------------------- I use LDPlayer and create Emulator. Im try so many type of model so this error still showing.
THIS IS INFORMATION OF UIAUTOMATOR 2 --------------------------------- pip show uiautomator2
Name: uiautomator2 Version: 2.16.13 Summary: Python Wrapper for Google Android UiAutomator2 test tool Home-page: https://github.com/openatx/uiautomator2 Author: codeskyblue Author-email: [email protected] License: MIT Location: c:\program files\python310\lib\site-packages Requires: adbutils, cached-property, Deprecated, filelock, logzero, lxml, packaging, Pillow, progress, requests, retry, six, whichcraft Required-by: weditor
WHEN I RUN ADB DEVICES - MY DEVICES IS ONLINE ---------------------------------
C:\LDPlayer\LDPlayer4.0>adb devices List of devices attached 127.0.0.1:5555 device
THIS ERROR ---------------------------------
[W 211228 17:41:13 init:218] [pid:10560] atx-agent has something wrong, auto recovering
[D 211228 17:41:13 init:322] [pid:10560] [127.0.0.1:5555] device 127.0.0.1:5555 is online
Traceback (most recent call last):
File "c:\Users\Admin\Desktop\twitter\test.py", line 3, in
Please help me. If want remote to check error can contact me at Telegram @Buihoan92. Thanks you so much
Is there a solution to this ? Having the same issue in 2023.
Source code:
import uiautomator2 as u2
d = u2.connect('emulator-5554')
d.press('back')
ADB devices output:
List of devices attached
emulator-5554 device
Error
[W 230309 13:20:29 __init__:218] [pid:11672] atx-agent has something wrong, auto recovering
[D 230309 13:20:29 __init__:317] [pid:11672] [emulator-5554] device emulator-5554 is online
Traceback (most recent call last):
File "C:\Users\icebox\AppData\Local\Programs\Python\Python38\lib\contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\uiautomator2\__init__.py", line 1034, in _operation_delay
yield
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\uiautomator2\__init__.py", line 1163, in press
return self.jsonrpc.pressKey(key)
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\uiautomator2\__init__.py", line 479, in __call__
return self.server._jsonrpc_retry_call(self.method, params,
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\uiautomator2\__init__.py", line 486, in _jsonrpc_retry_call
return self._jsonrpc_call(*args, **kwargs)
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\uiautomator2\__init__.py", line 512, in _jsonrpc_call
res = self.http.post("/jsonrpc/0",
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\requests\sessions.py", line 635, in post
return self.request("POST", url, data=data, json=json, **kwargs)
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\uiautomator2\__init__.py", line 223, in request
self.__client._prepare_atx_agent()
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\uiautomator2\__init__.py", line 318, in _prepare_atx_agent
version_url = self.path2url("/version")
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\uiautomator2\__init__.py", line 301, in path2url
return urlparse.urljoin(self._get_atx_agent_url(), path)
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\uiautomator2\__init__.py", line 282, in _get_atx_agent_url
lport = self._adb_device.forward_port(
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\adbutils\_device.py", line 244, in forward_port
for f in self.forward_list():
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\adbutils\_device.py", line 252, in forward_list
c = self.open_transport("list-forward")
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\adbutils\_device.py", line 89, in open_transport
c.check_okay()
File "C:\Users\icebox\Desktop\google\projects\gmaps-bot\venv\lib\site-packages\adbutils\_adb.py", line 134, in check_okay
raise AdbError(self.read_string_block())
adbutils.errors.AdbError: unknown host service
Solution: ldconsole.exe adb --name x --command "kill-server"