uiautomator2
uiautomator2 copied to clipboard
uiautomator2.UiAutomationNotConnectedError: -32001 Jsonrpc error: <java.lang.IllegalStateException> data: java.lang.IllegalStateException: UiAutomation not connected!
多次执行到如下步骤报错
if uiDevice.info.get('screenOn') != 'true':
报错信息:
File "D:\work\Python37\lib\site-packages\uiautomator2_init_.py", line 1063, in getattr
return getattr(self.default_session, attr)
File "D:\work\Python37\lib\site-packages\uiautomator2_init.py", line 1565, in info
return self.jsonrpc.deviceInfo()
File "D:\work\Python37\lib\site-packages\uiautomator2_init_.py", line 425, in call
params, http_timeout)
File "D:\work\Python37\lib\site-packages\uiautomator2_init_.py", line 432, in jsonrpc_retry_call
return self.jsonrpc_call(*args, **kwargs)
File "D:\work\Python37\lib\site-packages\uiautomator2_init_.py", line 505, in jsonrpc_call
raise err
uiautomator2.UiAutomationNotConnectedError: -32001 Jsonrpc error: <java.lang.IllegalStateException> data: java.lang.IllegalStateException: UiAutomation not connected!
at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1096)
at android.app.UiAutomation.waitForIdle(UiAutomation.java:647)
at android.support.test.uiautomator.QueryController.waitForIdle(QueryController.java:532)
at android.support.test.uiautomator.QueryController.waitForIdle(QueryController.java:523)
at android.support.test.uiautomator.QueryController.getCurrentPackageName(QueryController.java:511)
at android.support.test.uiautomator.UiDevice.getCurrentPackageName(UiDevice.java:653)
at com.github.uiautomator.stub.DeviceInfo.
不太好复现哎
之前没出现过这样,就这两天,出现的很频繁,但并不是每次必现 我是有100多个用例循环跑的,出现了很多次这个报错
我的一般是手机刚用usb连接电脑时候,运行程序会出现。怀疑和数据连接有关系。
现象
我这也遇到类似的问题,想问新版还有这问题么@codeskyblue u2:2.10.2,设备:华为mate9pro/安卓9.0
堆栈
[D 210525 10:02:16 __init__:595] kill process(ps): uiautomator
2021-05-25 10:02:16:962 : [D 210525 10:02:16 __init__:614] uiautomator-v2 is starting ... left: 40.0s
2021-05-25 10:02:17:724 : [D 210525 10:02:17 __init__:595] kill process(ps): uiautomator
2021-05-25 10:02:17:976 : [D 210525 10:02:17 __init__:614] uiautomator-v2 is starting ... left: 39.0s
2021-05-25 10:02:18:407 : [I 210525 10:02:18 __init__:567] restart-uiautomator since "-32001 Jsonrpc error: <java.lang.IllegalStateException> data: java.lang.IllegalStateException: UiAutomation not connected!
2021-05-25 10:02:18:408 : at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1116)
2021-05-25 10:02:18:408 : at android.app.UiAutomation.setRotation(UiAutomation.java:545)
2021-05-25 10:02:18:408 : at androidx.test.uiautomator.InteractionController.setRotationNatural(InteractionController.java:631)
2021-05-25 10:02:18:408 : at androidx.test.uiautomator.UiDevice.setOrientationNatural(UiDevice.java:853)
2021-05-25 10:02:18:408 : at com.github.uiautomator.stub.AutomatorServiceImpl.setOrientation(AutomatorServiceImpl.java:381)
2021-05-25 10:02:18:408 : at java.lang.reflect.Method.invoke(Native Method)
2021-05-25 10:02:18:408 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.invoke(JsonRpcBasicServer.java:467)
2021-05-25 10:02:18:408 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleObject(JsonRpcBasicServer.java:352)
2021-05-25 10:02:18:408 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleJsonNodeRequest(JsonRpcBasicServer.java:283)
2021-05-25 10:02:18:408 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleRequest(JsonRpcBasicServer.java:251)
2021-05-25 10:02:18:408 : at com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:100)
2021-05-25 10:02:18:408 : at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)
2021-05-25 10:02:18:408 : at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
2021-05-25 10:02:18:408 : at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
2021-05-25 10:02:18:408 : at java.lang.Thread.run(Thread.java:784)
2021-05-25 10:02:18:408 : , method: setOrientation"
2021-05-25 10:02:18:436 : [D 210525 10:02:18 __init__:595] kill process(ps): uiautomator
2021-05-25 10:02:18:679 : [D 210525 10:02:18 __init__:614] uiautomator-v2 is starting ... left: 40.0s
2021-05-25 10:02:18:696 : [D 210525 10:02:18 __init__:649] grant permissions
2021-05-25 10:02:19:108 : [I 210525 10:02:19 __init__:567] restart-uiautomator since "uiautomator2.GatewayError(gateway error, time used 0.0s)"
2021-05-25 10:02:19:166 : [D 210525 10:02:19 __init__:595] kill process(ps): uiautomator
2021-05-25 10:02:19:424 : [D 210525 10:02:19 __init__:649] grant permissions
2021-05-25 10:02:19:456 : [D 210525 10:02:19 __init__:614] uiautomator-v2 is starting ... left: 40.0s
2021-05-25 10:02:19:864 : Process Process-2:
2021-05-25 10:02:19:865 : Traceback (most recent call last):
2021-05-25 10:02:19:865 : File "/usr/local/lib/python3.7/site-packages/uiautomator2/__init__.py", line 438, in _jsonrpc_retry_call
2021-05-25 10:02:19:865 : return self._jsonrpc_call(*args, **kwargs)
2021-05-25 10:02:19:865 : File "/usr/local/lib/python3.7/site-packages/uiautomator2/__init__.py", line 510, in _jsonrpc_call
2021-05-25 10:02:19:865 : raise err
2021-05-25 10:02:19:865 : uiautomator2.exceptions.UiAutomationNotConnectedError: -32001 Jsonrpc error: <java.lang.IllegalStateException> data: java.lang.IllegalStateException: UiAutomation not connected!
2021-05-25 10:02:19:865 : at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1116)
2021-05-25 10:02:19:865 : at android.app.UiAutomation.setRotation(UiAutomation.java:545)
2021-05-25 10:02:19:865 : at androidx.test.uiautomator.InteractionController.setRotationNatural(InteractionController.java:631)
2021-05-25 10:02:19:865 : at androidx.test.uiautomator.UiDevice.setOrientationNatural(UiDevice.java:853)
2021-05-25 10:02:19:865 : at com.github.uiautomator.stub.AutomatorServiceImpl.setOrientation(AutomatorServiceImpl.java:381)
2021-05-25 10:02:19:865 : at java.lang.reflect.Method.invoke(Native Method)
2021-05-25 10:02:19:865 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.invoke(JsonRpcBasicServer.java:467)
2021-05-25 10:02:19:865 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleObject(JsonRpcBasicServer.java:352)
2021-05-25 10:02:19:865 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleJsonNodeRequest(JsonRpcBasicServer.java:283)
2021-05-25 10:02:19:865 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleRequest(JsonRpcBasicServer.java:251)
2021-05-25 10:02:19:866 : at com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:100)
2021-05-25 10:02:19:866 : at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)
2021-05-25 10:02:19:866 : at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
2021-05-25 10:02:19:866 : at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
2021-05-25 10:02:19:866 : at java.lang.Thread.run(Thread.java:784)
2021-05-25 10:02:19:866 : , method: setOrientation
2021-05-25 10:02:19:866 :
2021-05-25 10:02:19:866 : During handling of the above exception, another exception occurred:
2021-05-25 10:02:19:866 :
2021-05-25 10:02:19:866 : Traceback (most recent call last):
2021-05-25 10:02:19:866 : File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/suite.py", line 163, in _handleClassSetUp
2021-05-25 10:02:19:866 : setUpClass()
2021-05-25 10:02:19:866 : File "/Users/ssfanli/iMacNodeAndroid/workspace/p-e09c07a4ae644bbabe4cf69e2e3ebed7/src/utils/ut.py", line 73, in setUpClass
2021-05-25 10:02:19:866 : cold=cfg.getboolean('RUN', 'cold'))
2021-05-25 10:02:19:866 : File "/Users/ssfanli/iMacNodeAndroid/workspace/p-e09c07a4ae644bbabe4cf69e2e3ebed7/src/base/app.py", line 45, in start
2021-05-25 10:02:19:866 : self.d.set_orientation('n')
2021-05-25 10:02:19:866 : File "/usr/local/lib/python3.7/site-packages/uiautomator2/__init__.py", line 1090, in set_orientation
2021-05-25 10:02:19:866 : self.jsonrpc.setOrientation(values[1])
2021-05-25 10:02:19:867 : File "/usr/local/lib/python3.7/site-packages/uiautomator2/__init__.py", line 432, in __call__
2021-05-25 10:02:19:867 : http_timeout)
2021-05-25 10:02:19:867 : File "/usr/local/lib/python3.7/site-packages/uiautomator2/__init__.py", line 442, in _jsonrpc_retry_call
2021-05-25 10:02:19:867 : self.reset_uiautomator(str(e)) # uiautomator可能出问题了,强制重启一下
2021-05-25 10:02:19:867 : File "/usr/local/lib/python3.7/site-packages/uiautomator2/__init__.py", line 586, in reset_uiautomator
2021-05-25 10:02:19:867 : depth=depth + 1)
2021-05-25 10:02:19:867 : File "/usr/local/lib/python3.7/site-packages/uiautomator2/__init__.py", line 586, in reset_uiautomator
2021-05-25 10:02:19:867 : depth=depth + 1)
2021-05-25 10:02:19:867 : File "/usr/local/lib/python3.7/site-packages/uiautomator2/__init__.py", line 563, in reset_uiautomator
2021-05-25 10:02:19:867 : "adb shell am instrument -w -r -e debug false -e class com.github.uiautomator.stub.Stub com.github.uiautomator.test/android.support.test.runner.AndroidJUnitRunner",
2021-05-25 10:02:19:867 : OSError: [Errno Uiautomator started failed.] -32001 Jsonrpc error: <java.lang.IllegalStateException> data: java.lang.IllegalStateException: UiAutomation not connected!
2021-05-25 10:02:19:867 : at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1116)
2021-05-25 10:02:19:867 : at android.app.UiAutomation.setRotation(UiAutomation.java:545)
2021-05-25 10:02:19:867 : at androidx.test.uiautomator.InteractionController.setRotationNatural(InteractionController.java:631)
2021-05-25 10:02:19:867 : at androidx.test.uiautomator.UiDevice.setOrientationNatural(UiDevice.java:853)
2021-05-25 10:02:19:867 : at com.github.uiautomator.stub.AutomatorServiceImpl.setOrientation(AutomatorServiceImpl.java:381)
2021-05-25 10:02:19:867 : at java.lang.reflect.Method.invoke(Native Method)
2021-05-25 10:02:19:868 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.invoke(JsonRpcBasicServer.java:467)
2021-05-25 10:02:19:868 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleObject(JsonRpcBasicServer.java:352)
2021-05-25 10:02:19:868 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleJsonNodeRequest(JsonRpcBasicServer.java:283)
2021-05-25 10:02:19:868 : at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleRequest(JsonRpcBasicServer.java:251)
2021-05-25 10:02:19:868 : at com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:100)
2021-05-25 10:02:19:868 : at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)
2021-05-25 10:02:19:868 : at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
2021-05-25 10:02:19:868 : at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
2021-05-25 10:02:19:868 : at java.lang.Thread.run(Thread.java:784)
2021-05-25 10:02:19:868 : , method: setOrientation: 'https://github.com/openatx/uiautomator2/wiki/Common-issues'
Same issue with the emulator. The actual error:
[W 210828 16:54:04 __init__:209] [pid:8126] atx-agent has something wrong, auto recovering
[D 210828 16:54:04 __init__:297] [pid:8126] device 13.127.7.244:5555 is online
[I 210828 16:54:04 init:156] uiautomator2 version: 2.16.7
[D 210828 16:54:04 init:296] Real version: [0, 10, 0], Expect version: [0, 10, 0]
[D 210828 16:54:04 init:256] apk-debug package-info: {'package_name': 'com.github.uiautomator', 'version_name': '2.3.3', 'version_code': '2003003', 'flags': ['DEBUGGABLE', 'HAS_CODE', 'ALLOW_CLEAR_USER_DATA', 'ALLOW_BACKUP'], 'first_install_time': datetime.datetime(2021, 8, 27, 17, 14), 'last_update_time': datetime.datetime(2021, 8, 27, 17, 14), 'signature': 'ae17cd86'}
[D 210828 16:54:04 init:257] apk-debug-test package-info: {'package_name': 'com.github.uiautomator.test', 'version_name': '', 'version_code': '', 'flags': ['DEBUGGABLE', 'HAS_CODE', 'ALLOW_CLEAR_USER_DATA', 'ALLOW_BACKUP'], 'first_install_time': datetime.datetime(2021, 8, 27, 17, 14, 4), 'last_update_time': datetime.datetime(2021, 8, 27, 17, 14, 4), 'signature': 'ae17cd86'}
[D 210828 16:54:04 init:167] Shell: ('/data/local/tmp/atx-agent', 'server', '--nouia', '-d', '--addr', '127.0.0.1:7912')
[D 210828 16:54:04 init:397] Forward: local:tcp:37917 -> remote:tcp:7912
[D 210828 16:54:05 init:397] Forward: local:tcp:37917 -> remote:tcp:7912
[D 210828 16:54:05 init:400] atx-agent version 0.10.0
[D 210828 16:54:05 init:403] device wlan ip: 192.168.232.2
[D 210828 16:54:05 __init__:642] [pid:8126] kill process(ps): uiautomator
[D 210828 16:54:05 __init__:664] [pid:8126] uiautomator-v2 is starting ... left: 40.0s
[D 210828 16:54:07 __init__:664] [pid:8126] uiautomator-v2 is starting ... left: 39.0s
[I 210828 16:54:07 __init__:624] [pid:8126] uiautomator back to normal
{'currentPackageName': 'com.android.launcher3', 'displayHeight': 2278, 'displayRotation': 0, 'displaySizeDpX': 425, 'displaySizeDpY': 943, 'displayWidth': 1080, 'productName': 'cloud_arm', 'screenOn': True, 'sdkInt': 26, 'naturalOrientation': True}
[W 210828 16:54:09 __init__:209] [pid:8126] atx-agent has something wrong, auto recovering
[D 210828 16:54:09 __init__:297] [pid:8126] device 13.127.7.244:5555 is online
[I 210828 16:54:10 init:156] uiautomator2 version: 2.16.7
[D 210828 16:54:10 init:296] Real version: [0, 10, 0], Expect version: [0, 10, 0]
[D 210828 16:54:10 init:256] apk-debug package-info: {'package_name': 'com.github.uiautomator', 'version_name': '2.3.3', 'version_code': '2003003', 'flags': ['DEBUGGABLE', 'HAS_CODE', 'ALLOW_CLEAR_USER_DATA', 'ALLOW_BACKUP'], 'first_install_time': datetime.datetime(2021, 8, 27, 17, 14), 'last_update_time': datetime.datetime(2021, 8, 27, 17, 14), 'signature': 'ae17cd86'}
[D 210828 16:54:10 init:257] apk-debug-test package-info: {'package_name': 'com.github.uiautomator.test', 'version_name': '', 'version_code': '', 'flags': ['DEBUGGABLE', 'HAS_CODE', 'ALLOW_CLEAR_USER_DATA', 'ALLOW_BACKUP'], 'first_install_time': datetime.datetime(2021, 8, 27, 17, 14, 4), 'last_update_time': datetime.datetime(2021, 8, 27, 17, 14, 4), 'signature': 'ae17cd86'}
[D 210828 16:54:10 init:167] Shell: ('/data/local/tmp/atx-agent', 'server', '--nouia', '-d', '--addr', '127.0.0.1:7912')
[D 210828 16:54:10 init:397] Forward: local:tcp:37917 -> remote:tcp:7912
[D 210828 16:54:10 init:397] Forward: local:tcp:37917 -> remote:tcp:7912
[D 210828 16:54:11 init:400] atx-agent version 0.10.0
[D 210828 16:54:11 init:403] device wlan ip: 192.168.232.2
[D 210828 16:54:11 __init__:642] [pid:8126] kill process(ps): uiautomator
[D 210828 16:54:12 __init__:664] [pid:8126] uiautomator-v2 is starting ... left: 40.0s
[D 210828 16:54:13 __init__:664] [pid:8126] uiautomator-v2 is starting ... left: 39.0s
[D 210828 16:54:14 __init__:664] [pid:8126] uiautomator-v2 is starting ... left: 38.0s
[W 210828 16:54:14 __init__:209] [pid:8126] atx-agent has something wrong, auto recovering
[D 210828 16:54:14 __init__:297] [pid:8126] device 13.127.7.244:5555 is online
[I 210828 16:54:14 init:156] uiautomator2 version: 2.16.7
[D 210828 16:54:14 init:296] Real version: [0, 10, 0], Expect version: [0, 10, 0]
[D 210828 16:54:14 init:256] apk-debug package-info: {'package_name': 'com.github.uiautomator', 'version_name': '2.3.3', 'version_code': '2003003', 'flags': ['DEBUGGABLE', 'HAS_CODE', 'ALLOW_CLEAR_USER_DATA', 'ALLOW_BACKUP'], 'first_install_time': datetime.datetime(2021, 8, 27, 17, 14), 'last_update_time': datetime.datetime(2021, 8, 27, 17, 14), 'signature': 'ae17cd86'}
[D 210828 16:54:14 init:257] apk-debug-test package-info: {'package_name': 'com.github.uiautomator.test', 'version_name': '', 'version_code': '', 'flags': ['DEBUGGABLE', 'HAS_CODE', 'ALLOW_CLEAR_USER_DATA', 'ALLOW_BACKUP'], 'first_install_time': datetime.datetime(2021, 8, 27, 17, 14, 4), 'last_update_time': datetime.datetime(2021, 8, 27, 17, 14, 4), 'signature': 'ae17cd86'}
[D 210828 16:54:14 init:167] Shell: ('/data/local/tmp/atx-agent', 'server', '--nouia', '-d', '--addr', '127.0.0.1:7912')
[D 210828 16:54:14 init:397] Forward: local:tcp:37917 -> remote:tcp:7912
[D 210828 16:54:15 init:397] Forward: local:tcp:37917 -> remote:tcp:7912
[D 210828 16:54:16 init:400] atx-agent version 0.10.0
[D 210828 16:54:16 init:403] device wlan ip: 192.168.232.2
[I 210828 16:54:16 __init__:607] [pid:8126] restart-uiautomator since "-32001 Jsonrpc error: <java.lang.IllegalStateException> data: java.lang.IllegalStateException: UiAutomation not connected!
at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1043)
at android.app.UiAutomation.waitForIdle(UiAutomation.java:647)
at androidx.test.uiautomator.QueryController.waitForIdle(QueryController.java:532)
at androidx.test.uiautomator.QueryController.waitForIdle(QueryController.java:523)
at androidx.test.uiautomator.UiDevice.waitForIdle(UiDevice.java:621)
at androidx.test.uiautomator.UiDevice.getWindowRoots(UiDevice.java:1096)
at androidx.test.uiautomator.UiDevice.hasObject(UiDevice.java:137)
at androidx.test.uiautomator.Until$2.apply(Until.java:55)
at androidx.test.uiautomator.Until$2.apply(Until.java:52)
at androidx.test.uiautomator.WaitMixin.wait(WaitMixin.java:40)
at androidx.test.uiautomator.WaitMixin.wait(WaitMixin.java:34)
at androidx.test.uiautomator.UiDevice.wait(UiDevice.java:174)
at com.github.uiautomator.stub.AutomatorServiceImpl.waitForExists(AutomatorServiceImpl.java:1055)
at java.lang.reflect.Method.invoke(Native Method)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.invoke(JsonRpcBasicServer.java:467)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleObject(JsonRpcBasicServer.java:352)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleJsonNodeRequest(JsonRpcBasicServer.java:283)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleRequest(JsonRpcBasicServer.java:251)
at com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:100)
at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Thread.java:764)
, method: waitForExists"
[D 210828 16:54:16 __init__:642] [pid:8126] kill process(ps): uiautomator
[D 210828 16:54:17 __init__:704] [pid:8126] grant permissions
[D 210828 16:54:19 __init__:664] [pid:8126] uiautomator-v2 is starting ... left: 40.0s
[D 210828 16:54:20 __init__:664] [pid:8126] uiautomator-v2 is starting ... left: 39.0s
[D 210828 16:54:21 __init__:664] [pid:8126] uiautomator-v2 is starting ... left: 37.9s
[W 210828 16:54:21 __init__:209] [pid:8126] atx-agent has something wrong, auto recovering
[D 210828 16:54:21 __init__:297] [pid:8126] device 13.127.7.244:5555 is online
[I 210828 16:54:21 init:156] uiautomator2 version: 2.16.7
[D 210828 16:54:21 init:296] Real version: [0, 10, 0], Expect version: [0, 10, 0]
[D 210828 16:54:21 init:256] apk-debug package-info: {'package_name': 'com.github.uiautomator', 'version_name': '2.3.3', 'version_code': '2003003', 'flags': ['DEBUGGABLE', 'HAS_CODE', 'ALLOW_CLEAR_USER_DATA', 'ALLOW_BACKUP'], 'first_install_time': datetime.datetime(2021, 8, 27, 17, 14), 'last_update_time': datetime.datetime(2021, 8, 27, 17, 14), 'signature': 'ae17cd86'}
[D 210828 16:54:21 init:257] apk-debug-test package-info: {'package_name': 'com.github.uiautomator.test', 'version_name': '', 'version_code': '', 'flags': ['DEBUGGABLE', 'HAS_CODE', 'ALLOW_CLEAR_USER_DATA', 'ALLOW_BACKUP'], 'first_install_time': datetime.datetime(2021, 8, 27, 17, 14, 4), 'last_update_time': datetime.datetime(2021, 8, 27, 17, 14, 4), 'signature': 'ae17cd86'}
[D 210828 16:54:21 init:167] Shell: ('/data/local/tmp/atx-agent', 'server', '--nouia', '-d', '--addr', '127.0.0.1:7912')
[D 210828 16:54:21 init:397] Forward: local:tcp:37917 -> remote:tcp:7912
[D 210828 16:54:22 init:397] Forward: local:tcp:37917 -> remote:tcp:7912
[D 210828 16:54:22 init:397] Forward: local:tcp:37917 -> remote:tcp:7912
[D 210828 16:54:23 init:400] atx-agent version 0.10.0
[D 210828 16:54:23 init:403] device wlan ip: 192.168.232.2
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.6/site-packages/uiautomator2/__init__.py", line 465, in _jsonrpc_retry_call
return self._jsonrpc_call(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.6/site-packages/uiautomator2/__init__.py", line 537, in _jsonrpc_call
raise err
uiautomator2.exceptions.UiAutomationNotConnectedError: -32001 Jsonrpc error: <java.lang.IllegalStateException> data: java.lang.IllegalStateException: UiAutomation not connected!
at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1043)
at android.app.UiAutomation.waitForIdle(UiAutomation.java:647)
at androidx.test.uiautomator.QueryController.waitForIdle(QueryController.java:532)
at androidx.test.uiautomator.QueryController.waitForIdle(QueryController.java:523)
at androidx.test.uiautomator.UiDevice.waitForIdle(UiDevice.java:621)
at androidx.test.uiautomator.UiDevice.getWindowRoots(UiDevice.java:1096)
at androidx.test.uiautomator.UiDevice.hasObject(UiDevice.java:137)
at androidx.test.uiautomator.Until$2.apply(Until.java:55)
at androidx.test.uiautomator.Until$2.apply(Until.java:52)
at androidx.test.uiautomator.WaitMixin.wait(WaitMixin.java:40)
at androidx.test.uiautomator.WaitMixin.wait(WaitMixin.java:34)
at androidx.test.uiautomator.UiDevice.wait(UiDevice.java:174)
at com.github.uiautomator.stub.AutomatorServiceImpl.waitForExists(AutomatorServiceImpl.java:1055)
at java.lang.reflect.Method.invoke(Native Method)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.invoke(JsonRpcBasicServer.java:467)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleObject(JsonRpcBasicServer.java:352)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleJsonNodeRequest(JsonRpcBasicServer.java:283)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleRequest(JsonRpcBasicServer.java:251)
at com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:100)
at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Thread.java:764)
, method: waitForExists
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "index.py", line 318, in <module>
SetMockLocation(1.356297, 103.819838)
File "index.py", line 25, in SetMockLocation
d(description='More options').click() # Clicking the More options button.
File "/home/ubuntu/.local/lib/python3.6/site-packages/uiautomator2/_selector.py", line 150, in click
self.must_wait(timeout=timeout)
File "/home/ubuntu/.local/lib/python3.6/site-packages/uiautomator2/_selector.py", line 344, in must_wait
if not self.wait(exists, timeout):
File "/home/ubuntu/.local/lib/python3.6/site-packages/uiautomator2/_selector.py", line 316, in wait
http_timeout=http_wait)
File "/home/ubuntu/.local/lib/python3.6/site-packages/uiautomator2/__init__.py", line 459, in __call__
http_timeout)
File "/home/ubuntu/.local/lib/python3.6/site-packages/uiautomator2/__init__.py", line 469, in _jsonrpc_retry_call
self.reset_uiautomator(str(e)) # uiautomator可能出问题了,强制重启一下
File "/home/ubuntu/.local/lib/python3.6/site-packages/uiautomator2/__init__.py", line 633, in reset_uiautomator
depth=depth + 1)
File "/home/ubuntu/.local/lib/python3.6/site-packages/uiautomator2/__init__.py", line 633, in reset_uiautomator
depth=depth + 1)
File "/home/ubuntu/.local/lib/python3.6/site-packages/uiautomator2/__init__.py", line 603, in reset_uiautomator
"adb shell am instrument -w -r -e debug false -e class com.github.uiautomator.stub.Stub com.github.uiautomator.test/android.support.test.runner.AndroidJUnitRunner",
OSError: [Errno Uiautomator started failed.] -32001 Jsonrpc error: <java.lang.IllegalStateException> data: java.lang.IllegalStateException: UiAutomation not connected!
at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1043)
at android.app.UiAutomation.waitForIdle(UiAutomation.java:647)
at androidx.test.uiautomator.QueryController.waitForIdle(QueryController.java:532)
at androidx.test.uiautomator.QueryController.waitForIdle(QueryController.java:523)
at androidx.test.uiautomator.UiDevice.waitForIdle(UiDevice.java:621)
at androidx.test.uiautomator.UiDevice.getWindowRoots(UiDevice.java:1096)
at androidx.test.uiautomator.UiDevice.hasObject(UiDevice.java:137)
at androidx.test.uiautomator.Until$2.apply(Until.java:55)
at androidx.test.uiautomator.Until$2.apply(Until.java:52)
at androidx.test.uiautomator.WaitMixin.wait(WaitMixin.java:40)
at androidx.test.uiautomator.WaitMixin.wait(WaitMixin.java:34)
at androidx.test.uiautomator.UiDevice.wait(UiDevice.java:174)
at com.github.uiautomator.stub.AutomatorServiceImpl.waitForExists(AutomatorServiceImpl.java:1055)
at java.lang.reflect.Method.invoke(Native Method)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.invoke(JsonRpcBasicServer.java:467)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleObject(JsonRpcBasicServer.java:352)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleJsonNodeRequest(JsonRpcBasicServer.java:283)
at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleRequest(JsonRpcBasicServer.java:251)
at com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:100)
at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Thread.java:764)
, method: waitForExists: 'https://github.com/openatx/uiautomator2/wiki/Common-issues'
Observed same issue on Android.
2022-01-12 06:20:06,684 [WARNING] retry.api: uiautomator2.GatewayError(gateway error, time used 0.1s), retrying in 3.0 seconds... [D 220112 06:20:09 __init__:697] force reset uiautomator [D 220112 06:20:09 __init__:721] Product-brand: Amazon [D 220112 06:20:14 __init__:740] uiautomator is starting ... [I 220112 06:20:16 __init__:701] uiautomator back to normal [D 220112 06:23:17 __init__:514] UiAutomation not connected, restart uiautomator 2022-01-12 06:23:17,528 [WARNING] retry.api: -32001 Jsonrpc error: <java.lang.IllegalStateException> data: java.lang.IllegalStateException: UiAutomation not connected! at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1034) at android.app.UiAutomation.waitForIdle(UiAutomation.java:638) at android.support.test.uiautomator.QueryController.waitForIdle(QueryController.java:532) at android.support.test.uiautomator.QueryController.waitForIdle(QueryController.java:523) at android.support.test.uiautomator.UiDevice.waitForIdle(UiDevice.java:621) at android.support.test.uiautomator.UiDevice.getWindowRoots(UiDevice.java:1096) at android.support.test.uiautomator.UiDevice.hasObject(UiDevice.java:137) at android.support.test.uiautomator.Until$2.apply(Until.java:55) at android.support.test.uiautomator.Until$2.apply(Until.java:52) at android.support.test.uiautomator.WaitMixin.wait(WaitMixin.java:49) at android.support.test.uiautomator.WaitMixin.wait(WaitMixin.java:34) at android.support.test.uiautomator.UiDevice.wait(UiDevice.java:174) at com.github.uiautomator.stub.AutomatorServiceImpl.waitForExists(AutomatorServiceImpl.java:986) at java.lang.reflect.Method.invoke(Native Method) at com.googlecode.jsonrpc4j.JsonRpcBasicServer.invoke(JsonRpcBasicServer.java:467) at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleObject(JsonRpcBasicServer.java:352) at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleJsonNodeRequest(JsonRpcBasicServer.java:283) at com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleRequest(JsonRpcBasicServer.java:251) at com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:100) at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244) at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945) at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192) at java.lang.Thread.run(Thread.java:761) , method: waitForExists, retrying in 3.5 seconds...
Same problem occurs after decades of fling where hundreds of items are downloaded step by step with fling. It seems to be outcome of memory! I have no idea how to solve it.
同样遇到这个问题,长时间运行之后出现,莫名就断开 1.adb shell 进程还在,重启进程没有效果 2.目前只有执行python3 -m uiautomator2 init ,这个命令才会重新被识别到 这个问题有解决办法吗
修改源代码 指定版本
Calling python -m uiautomator2 init
fixed it for me
有个简单的办法,把 App(log小黄车)的悬浮窗权限打开就行。 https://zhuanlan.zhihu.com/p/688009468