Closed qingqingcaoyuanlin closed 1 month ago
日志参考如下:
D:\xxx>python -m uiautomator2 screenshot [D 2024-07-16 17:07:21,513 core:204 pid:14456] use apk_version: 2.4.0 [D 2024-07-16 17:07:23,343 core:90 pid:14456] http request GET /ping None [D 2024-07-16 17:07:23,344 core:92 pid:14456] forward tcp:62518 -> tcp:9008 [D 2024-07-16 17:07:23,352 core:66 pid:14456] launch uiautomator [D 2024-07-16 17:07:26,925 core:35 pid:14456] MockAdbProcess: b'INSTRUMENTATION_STATUS: numtests=1\r\nINSTRUMENTATION_STATUS: stream=\r\ncom.github.uiautomator.stub.Stub:\r\nINSTRUMENTATION_STATUS: id=AndroidJUnitRunner\r\nINSTRUMENTATION_STATUS: test=testUIAutomatorStub\r\nINSTRUMENTATION_STATUS: class=com.github.uiautomator.stub.Stub\r\nINSTRUMENTATION_STATUS: current=1\r\nINSTRUMENTATION_STATUS_CODE: 1\r\n' [D 2024-07-16 17:07:27,169 core:247 pid:14456] am instrument success, status_code: 1 [D 2024-07-16 17:07:28,308 core:90 pid:14456] http request GET /ping None [D 2024-07-16 17:07:28,309 core:92 pid:14456] forward tcp:62518 -> tcp:9008 [D 2024-07-16 17:07:29,346 core:90 pid:14456] http request POST /jsonrpc/0 {'jsonrpc': '2.0', 'id': 1, 'method': 'takeScreenshot', 'params': (1, 80)} [D 2024-07-16 17:07:29,349 core:92 pid:14456] forward tcp:62518 -> tcp:9008 [D 2024-07-16 17:07:29,622 core:132 pid:14456] jsonrpc error: {'jsonrpc': '2.0', 'id': 1, 'error': {'code': -32001, 'message': 'java.lang.NoClassDefFoundError', 'data': 'java.lang.NoClassDefFoundError: Failed resolution of: Ljava/util/Base64;\n\tat com.github.uiautomator.stub.AutomatorServiceImpl.takeScreenshot(AutomatorServiceImpl.java:341)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.googlecode.jsonrpc4j.JsonRpcBasicServer.invoke(JsonRpcBasicServer.java:467)\n\tat com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleObject(JsonRpcBasicServer.java:352)\n\tat com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleJsonNodeRequest(JsonRpcBasicServer.java:283)\n\tat com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleRequest(JsonRpcBasicServer.java:251)\n\tat com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:100)\n\tat fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)\n\tat fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)\n\tat fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)\n\tat java.lang.Thread.run(Thread.java:818)\nCaused by: java.lang.ClassNotFoundException: Didn\'t find class "java.util.Base64" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.github.uiautomator.test-1/base.apk", zip file "/data/app/com.github.uiautomator-1/base.apk"],nativeLibraryDirectories=[/data/app/com.github.uiautomator.test-1/lib/arm64, /data/app/com.github.uiautomator-1/lib/arm64, /vendor/lib64, /system/lib64]]\n\tat dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)\n\tat java.lang.ClassLoader.loadClass(ClassLoader.java:511)\n\tat java.lang.ClassLoader.loadClass(ClassLoader.java:469)\n\t... 11 more\n\tSuppressed: java.lang.ClassNotFoundException: java.util.Base64\n\t\tat java.lang.Class.classForName(Native Method)\n\t\tat java.lang.BootClassLoader.findClass(ClassLoader.java:781)\n\t\tat java.lang.BootClassLoader.loadClass(ClassLoader.java:841)\n\t\tat java.lang.ClassLoader.loadClass(ClassLoader.java:504)\n\t\t... 12 more\n\tCaused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available\n'}} [D 2024-07-16 17:07:29,623 core:304 pid:14456] uiautomator2 is not ok, error: android.os.DeadSystemRuntimeException [D 2024-07-16 17:07:29,624 core:90 pid:14456] http request GET /ping None [D 2024-07-16 17:07:29,625 core:92 pid:14456] forward tcp:62518 -> tcp:9008 [D 2024-07-16 17:07:30,165 core:90 pid:14456] http request GET /ping None [D 2024-07-16 17:07:30,168 core:92 pid:14456] forward tcp:62518 -> tcp:9008 [D 2024-07-16 17:07:30,197 core:204 pid:14456] use apk_version: 2.4.0 [D 2024-07-16 17:07:32,056 core:90 pid:14456] http request GET /ping None [D 2024-07-16 17:07:32,058 core:92 pid:14456] forward tcp:62518 -> tcp:9008 [D 2024-07-16 17:07:32,069 core:66 pid:14456] launch uiautomator [D 2024-07-16 17:07:35,647 core:35 pid:14456] MockAdbProcess: b'INSTRUMENTATION_STATUS: numtests=1\r\nINSTRUMENTATION_STATUS: stream=\r\ncom.github.uiautomator.stub.Stub:\r\nINSTRUMENTATION_STATUS: id=AndroidJUnitRunner\r\nINSTRUMENTATION_STATUS: test=testUIAutomatorStub\r\nINSTRUMENTATION_STATUS: class=com.github.uiautomator.stub.Stub\r\nINSTRUMENTATION_STATUS: current=1\r\nINSTRUMENTATION_STATUS_CODE: 1\r\n' [D 2024-07-16 17:07:35,857 core:247 pid:14456] am instrument success, status_code: 1 [D 2024-07-16 17:07:37,001 core:281 pid:14456] show float window [D 2024-07-16 17:07:38,209 core:90 pid:14456] http request GET /ping None [D 2024-07-16 17:07:38,210 core:92 pid:14456] forward tcp:62518 -> tcp:9008 [D 2024-07-16 17:07:39,271 core:90 pid:14456] http request POST /jsonrpc/0 {'jsonrpc': '2.0', 'id': 1, 'method': 'takeScreenshot', 'params': (1, 80)} [D 2024-07-16 17:07:39,272 core:92 pid:14456] forward tcp:62518 -> tcp:9008 [D 2024-07-16 17:07:39,506 core:132 pid:14456] jsonrpc error: {'jsonrpc': '2.0', 'id': 1, 'error': {'code': -32001, 'message': 'java.lang.NoClassDefFoundError', 'data': 'java.lang.NoClassDefFoundError: Failed resolution of: Ljava/util/Base64;\n\tat com.github.uiautomator.stub.AutomatorServiceImpl.takeScreenshot(AutomatorServiceImpl.java:341)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.googlecode.jsonrpc4j.JsonRpcBasicServer.invoke(JsonRpcBasicServer.java:467)\n\tat com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleObject(JsonRpcBasicServer.java:352)\n\tat com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleJsonNodeRequest(JsonRpcBasicServer.java:283)\n\tat com.googlecode.jsonrpc4j.JsonRpcBasicServer.handleRequest(JsonRpcBasicServer.java:251)\n\tat com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:100)\n\tat fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)\n\tat fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)\n\tat fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)\n\tat java.lang.Thread.run(Thread.java:818)\nCaused by: java.lang.ClassNotFoundException: Didn\'t find class "java.util.Base64" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.github.uiautomator.test-1/base.apk", zip file "/data/app/com.github.uiautomator-1/base.apk"],nativeLibraryDirectories=[/data/app/com.github.uiautomator.test-1/lib/arm64, /data/app/com.github.uiautomator-1/lib/arm64, /vendor/lib64, /system/lib64]]\n\tat dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)\n\tat java.lang.ClassLoader.loadClass(ClassLoader.java:511)\n\tat java.lang.ClassLoader.loadClass(ClassLoader.java:469)\n\t... 11 more\n\tSuppressed: java.lang.ClassNotFoundException: java.util.Base64\n\t\tat java.lang.Class.classForName(Native Method)\n\t\tat java.lang.BootClassLoader.findClass(ClassLoader.java:781)\n\t\tat java.lang.BootClassLoader.loadClass(ClassLoader.java:841)\n\t\tat java.lang.ClassLoader.loadClass(ClassLoader.java:504)\n\t\t... 12 more\n\tCaused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available\n'}} Traceback (most recent call last): File "C:\Python39\lib\site-packages\uiautomator2\core.py", line 302, in jsonrpc_call return _jsonrpc_call(self._dev, method, params, timeout, self._debug) File "C:\Python39\lib\site-packages\uiautomator2\core.py", line 142, in _jsonrpc_call raise UiAutomationNotConnectedError("android.os.DeadSystemRuntimeException") uiautomator2.exceptions.UiAutomationNotConnectedError: android.os.DeadSystemRuntimeException During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Python39\lib\site-packages\uiautomator2\__main__.py", line 256, in <module> main() File "C:\Python39\lib\site-packages\uiautomator2\__main__.py", line 248, in main actions[args.subparser](args) File "C:\Python39\lib\site-packages\uiautomator2\__main__.py", line 53, in cmd_screenshot d.screenshot().save(args.filename) File "C:\Python39\lib\site-packages\uiautomator2\__init__.py", line 259, in screenshot base64_data = self.jsonrpc.takeScreenshot(1, 80) File "C:\Python39\lib\site-packages\uiautomator2\__init__.py", line 186, in __call__ return self.server.jsonrpc_call(self.method, params, http_timeout) File "C:\Python39\lib\site-packages\uiautomator2\core.py", line 307, in jsonrpc_call return _jsonrpc_call(self._dev, method, params, timeout, self._debug) File "C:\Python39\lib\site-packages\uiautomator2\core.py", line 142, in _jsonrpc_call raise UiAutomationNotConnectedError("android.os.DeadSystemRuntimeException") uiautomator2.exceptions.UiAutomationNotConnectedError: android.os.DeadSystemRuntimeException
在网上找到相关解决办法:链接
关闭此问题,转到android-uiautomator-server项目
提在这里也可以,会在3.2.0修复
日志参考如下:
在网上找到相关解决办法:链接