uiautomator2 icon indicating copy to clipboard operation
uiautomator2 copied to clipboard

Android 12 下兼容性出现问题,运行一段时间后会无法连接

Open icegourd opened this issue 3 years ago • 2 comments

之前测试代码运行都很正常,手机升级为Android12后,运行测试代码刚开始还正常,但是很短时间内就会出现异常,无法重新连接上。 出现错误代码如下:

[E 211013 13:13:24 web:2250] 500 GET /api/v2/devices/android%AAAAAAAA/hierarchy (::1) 425.75ms [I 211013 13:17:07 page:297] Serial: AAAAAAAA [I 211013 13:17:13 web:2250] 200 GET /api/v1/devices/android%AAAAAAAA/screenshot (::1) 5580.32ms [W 211013 13:17:13 init:471] [pid:3964] jsonrpc call got: -32001 Jsonrpc error: <java.lang.NullPointerException> data: java.lang.NullPointerException: Attempt to read from field 'int android.accessibilityservice.AccessibilityServiceInfo.flags' on a null object reference at androidx.test.uiautomator.UiDevice.setCompressedLayoutHeirarchy(UiDevice.java:234) at com.github.uiautomator.stub.AutomatorServiceImpl.dumpWindowHierarchy(AutomatorServiceImpl.java:295) at com.github.uiautomator.stub.AutomatorServiceImpl.dumpWindowHierarchy(AutomatorServiceImpl.java:284) 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:920) , method: dumpWindowHierarchy

我怀疑是uiautomater服务出了问题,因为如果手动在 ATX APP中点击“停止UIAUTOMATOR”按钮后,这时候运行测试代码,获得的错误信息是一样的。

进一步确定uiautomater服务停止了: 出现问题后

  1. 在weditor中执行 d.uiautomator.running() 返回false
  2. 执行 atx-agent 的curl命令,同样返回false adb shell /data/local/tmp/atx-agent curl http://127.0.0.1:7912/services/uiautomator 2021/10/13 14:45:46 goreq.go:390: GET /services/uiautomator HTTP/1.1 Host: 127.0.0.1:7912 2021/10/13 14:45:46 curl.go:116: {"running":false,"success":true}
  • 手机型号 Nokia X10(Android 12)

  • uiautomator2的版本号(pip show uiautomator2) Version: 2.16.7

  • 手机截图

  • 相关日志(Python控制台错误信息, adb logcat完整信息, atxagent.log日志)

Screenshot_20211013-140309 atx-agent.daemon.log atx-agent.log

Python 出现3次下列错误消息后问题出现:

_[W 211013 14:59:51 init:207] [pid:14892] atx-agent has something wrong, auto recovering [D 211013 14:59:51 init:295] [pid:14892] device ASCALTH005M22400198 is online [I 211013 14:59:52 init:159] uiautomator2 version: 2.16.7 [D 211013 14:59:53 init:299] Real version: [0, 10, 0], Expect version: [0, 10, 0] [D 211013 14:59:53 init:259] 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, 10, 13, 12, 30, 12), 'last_update_time': datetime.datetime(2021, 10, 13, 12, 30, 12), 'signature': 'ae17cd86], past signatures:['} [D 211013 14:59:53 init:260] 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, 10, 13, 12, 30, 14), 'last_update_time': datetime.datetime(2021, 10, 13, 12, 30, 14), 'signature': 'ae17cd86], past signatures:['} [D 211013 14:59:53 init:170] Shell: ('/data/local/tmp/atx-agent', 'server', '--nouia', '-d', '--addr', '0.0.0.0:7912') [D 211013 14:59:53 init:400] Forward: local:tcp:49899 -> remote:tcp:7912 2021Oct13-14:59:53.585 WARNING [retry.api] [_retry_internal] ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')), retrying in 0.5 seconds... [D 211013 14:59:54 init:400] Forward: local:tcp:49899 -> remote:tcp:7912 [D 211013 14:59:54 init:403] atx-agent version 0.10.0 [D 211013 14:59:54 init:406] device wlan ip: 10.231.12.85

icegourd avatar Oct 13 '21 06:10 icegourd

+1

killaragorn avatar Jul 04 '23 02:07 killaragorn

Did you find a fix for this? Happens to me also 😢

chrisjansky avatar Sep 14 '23 08:09 chrisjansky