openatx / uiautomator2

Android Uiautomator2 Python Wrapper
MIT License
6.4k stars 1.38k forks source link

一加手机,安卓8.1.0,命令出现异常,且安卓apk出现闪退 #151

Closed wakelay closed 4 months ago

wakelay commented 6 years ago
>>> import uiautomator2 as u2
>>> d=u2.connect_usb()
>>> d.info

Versions (版本)

Version: 0.1.2

Issue and steps to reproduce (复现步骤)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/init.py", line 985, in getattr return getattr(self._default_session, attr) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/init.py", line 1423, in info return self.jsonrpc.deviceInfo() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/init.py", line 349, in call params, http_timeout) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/init.py", line 363, in jsonrpc_retry_call self.healthcheck(unlock=False) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/init.py", line 525, in healthcheck raise RuntimeError("Uiautomator started failed.") RuntimeError: Uiautomator started failed.

codeskyblue commented 6 years ago

确定init成功了

wakelay commented 6 years ago

确认了下 init过程就会失败 log如下:

2018-07-04 18:13:46,413 - __main__.py:269 - INFO - Detect pluged devices: ['1e013124']
2018-07-04 18:13:46,414 - __main__.py:286 - INFO - Device(1e013124) initialing ...
2018-07-04 18:13:46,773 - __main__.py:113 - INFO - install minicap
2018-07-04 18:13:46,882 - __main__.py:120 - INFO - install minitouch
2018-07-04 18:13:47,093 - __main__.py:137 - INFO - apk(1.1.0) already installed, skip
2018-07-04 18:13:47,150 - __main__.py:175 - INFO - atx-agent(0.3.3) already installed, skip
2018-07-04 18:13:47,272 - __main__.py:212 - INFO - launch atx-agent daemon
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/util/retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/packages/six.py", line 686, in reraise
    raise value
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py", line 306, in _raise_timeout
    raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=55371): Read timed out. (read timeout=3)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/__main__.py", line 356, in <module>
    main()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/__main__.py", line 352, in main
    fire.Fire(MyFire)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/fire/core.py", line 127, in Fire
    component_trace = _Fire(component, args, context, name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/fire/core.py", line 366, in _Fire
    component, remaining_args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/fire/core.py", line 542, in _CallCallable
    result = fn(*varargs, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/__main__.py", line 273, in init
    ignore_apk_check)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/__main__.py", line 295, in _init_with_serial
    ins.launch_and_check()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/__main__.py", line 225, in launch_and_check
    'http://localhost:%d/version' % lport, timeout=3)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/adapters.py", line 526, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='localhost', port=55371): Read timed out. (read timeout=3)

手动启动安卓apk闪退几次后能成功启动,但是执行healthcheck()再次异常:

>>> import uiautomator2 as u2
>>> d=u2.connect_usb()
>>> d.info
{'currentPackageName': 'net.oneplus.launcher', 'displayHeight': 2154, 'displayRotation': 0, 'displaySizeDpX': 411, 'displaySizeDpY': 869, 'displayWidth': 1080, 'productName': 'OnePlus6', 'screenOn': True, 'sdkInt': 27, 'naturalOrientation': True}
>>> d.healthcheck()
Wed Jul  4 18:17:01 2018 wait uiautomator is ready.
Wed Jul  4 18:17:02 2018 wait uiautomator is ready.
Wed Jul  4 18:17:03 2018 wait uiautomator is ready.
Wed Jul  4 18:17:04 2018 wait uiautomator is ready.
Wed Jul  4 18:17:05 2018 wait uiautomator is ready.
Wed Jul  4 18:17:06 2018 wait uiautomator is ready.
Wed Jul  4 18:17:07 2018 wait uiautomator is ready.
Wed Jul  4 18:17:08 2018 wait uiautomator is ready.
Wed Jul  4 18:17:09 2018 wait uiautomator is ready.
Wed Jul  4 18:17:10 2018 wait uiautomator is ready.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/uiautomator2/__init__.py", line 525, in healthcheck
    raise RuntimeError("Uiautomator started failed.")
RuntimeError: Uiautomator started failed.
codeskyblue commented 6 years ago

1+是有点奇怪,需要特殊处理。之前集群上还有这个手机的,后来嫌麻烦就把手机拿下来了

wakelay commented 6 years ago

另外,升级了一下,升到0.1.2之后swipe操作不生效了,直接返回false

OnTheWay111 commented 5 years ago

锤子M1L手机也有这个问题

mingyuan-xia commented 5 years ago

尝试手工启动

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.