Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalArgumentException: Illegal character #207

Closed
dedecn opened this issue Aug 30, 2018 · 12 comments
Closed

java.lang.IllegalArgumentException: Illegal character #207

dedecn opened this issue Aug 30, 2018 · 12 comments
Labels

Comments

@dedecn
Copy link

dedecn commented Aug 30, 2018

报错log如下

[E 180830 09:46:31 web:1621] Uncaught exception GET /api/v1/devices/db71650b-4680-4056-9332-b0f84e778c68/hierarchy (::1)
    HTTPServerRequest(protocol='http', host='localhost:17310', method='GET', uri='/api/v1/devices/db71650b-4680-4056-9332-b0f84e778c68/hierarchy', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "C:\Python27\lib\site-packages\tornado\web.py", line 1541, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "C:\Python27\lib\site-packages\weditor\__main__.py", line 272, in get
        self.write(uidumplib.get_android_hierarchy(d))
      File "C:\Python27\lib\site-packages\weditor\uidumplib.py", line 103, in get_android_hierarchy
        page_xml = d.dump_hierarchy(compressed=False, pretty=False).encode('utf-8')
      File "<decorator-gen-4>", line 2, in dump_hierarchy
      File "C:\Python27\lib\site-packages\retry\api.py", line 74, in retry_decorator
        logger)
      File "C:\Python27\lib\site-packages\retry\api.py", line 33, in __retry_internal
        return f()
      File "C:\Python27\lib\site-packages\uiautomator2\__init__.py", line 1415, in dump_hierarchy
        content = self.jsonrpc.dumpWindowHierarchy(compressed, None)
      File "C:\Python27\lib\site-packages\uiautomator2\__init__.py", line 398, in __call__
        params, http_timeout)
      File "C:\Python27\lib\site-packages\uiautomator2\__init__.py", line 405, in jsonrpc_retry_call
        return self.jsonrpc_call(*args, **kwargs)
      File "C:\Python27\lib\site-packages\uiautomator2\__init__.py", line 483, in jsonrpc_call
        raise err
    JsonRpcError: -32001 Jsonrpc error: <java.lang.IllegalArgumentException> data: java.lang.IllegalArgumentException: Illegal character (d83d)
        at org.kxml2.io.KXmlSerializer.reportInvalidCharacter(KXmlSerializer.java:144)
        at org.kxml2.io.KXmlSerializer.writeEscaped(KXmlSerializer.java:130)
        at org.kxml2.io.KXmlSerializer.attribute(KXmlSerializer.java:465)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:63)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpNodeRec(AccessibilityNodeInfoDumper.java:86)
        at android.support.test.uiautomator.AccessibilityNodeInfoDumper.dumpWindowHierarchy(AccessibilityNodeInfoDumper.java:50)
        at android.support.test.uiautomator.UiDevice.dumpWindowHierarchy(UiDevice.java:945)
        at com.github.uiautomator.stub.AutomatorServiceImpl.dumpWindowHierarchy(AutomatorServiceImpl.java:239)
        at com.github.uiautomator.stub.AutomatorServiceImpl.dumpWindowHierarchy(AutomatorServiceImpl.java:225)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        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:841)
    , method: dumpWindowHierarchy

Versions (版本)

0.1.4.dev21

Issue and steps to reproduce (复现步骤)

在微博app页面,我关注的人,用WEditor获取界面层级,报这个错,应该是jsonrpc序列化/反序列化时不支持某些字符

用的夜神模拟器

@dedecn
Copy link
Author

dedecn commented Aug 30, 2018

应该是android.support.test.uiautomator的版本比较低,可以升一下版本吗?
我看android他们源码已经修了这个问题
https://android.googlesource.com/platform/frameworks/testing/+/2b6d1da16a4e38a9704c2c67b33aadf44a85b1d2

@codeskyblue
Copy link
Member

image
2014年改的,现在肯定已经升级过了

@dedecn
Copy link
Author

dedecn commented Aug 30, 2018

image

从android源码的diff看,新代码的这个函数是用StringBuilder了,但从以下地址下载的apk反编译后看到的这个函数还是用旧代码的StringBuffer

image

apk下载地址是
https://github.com/openatx/android-uiautomator-server/releases/download/1.1.5/app-uiautomator-test.apk

会不会是这个apk编译时用的lib还是旧版本的?

@dedecn
Copy link
Author

dedecn commented Aug 30, 2018

@dedecn
Copy link
Author

dedecn commented Aug 30, 2018

@codeskyblue
Copy link
Member

android.support.test.uiautomator 已经最新了
https://github.com/openatx/android-uiautomator-server/blob/master/app/build.gradle#L96
编译是在trivis上编译的

@codeskyblue
Copy link
Member

我的java不是很精通,你有什么修改的意见吗?

@mingyuan-xia
Copy link
Member

欢迎在android-uiautomator-server PR

@mingyuan-xia
Copy link
Member

目前maven上google发布的最新版本的 https://mvnrepository.com/artifact/com.android.support.test.uiautomator/uiautomator-v18/2.1.3
还是用的StringBuffer这个老版本,说明14年这个没有发布。我看了下最新的代码:
https://android.googlesource.com/platform/frameworks/testing/+/master/uiautomator/library/core-src/com/android/uiautomator/core/AccessibilityNodeInfoDumper.java
自14年这个commit后就没有更新,解决方案可从googlesource弄下来,build出jar来以来,放弃maven的旧版本

@mingyuan-xia
Copy link
Member

方案是直接拷贝新代码过来去除这个旧依赖 我来弄

@codeskyblue
Copy link
Member

codeskyblue commented Nov 27, 2018

代码我抠出来了,暂时没有弄jar包,直接把AccessibilityNodeInfoDumper的代码放到了这个项目里面。
参见 https://github.com/openatx/android-uiautomator-server/tree/fix-dump @mingyuan-xia

@mingyuan-xia
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants