xiaocong / uiautomator

Python wrapper of Android uiautomator test tool.
MIT License
2.02k stars 638 forks source link

uiautomator.JsonRPCError: UiAutomationService not connected #183

Open chicharitomu14 opened 7 years ago

chicharitomu14 commented 7 years ago

Hi xiaocong, I am doing UI test on Android 4.1, python 2.7, but I am getting an error about UiAutomationService not connected. I want to know how to solve it. Thank you.
File "/usr/local/lib/python2.7/dist-packages/uiautomator/init.py", line 602, in dump content = self.server.jsonrpc.dumpWindowHierarchy(compressed, None) File "/usr/local/lib/python2.7/dist-packages/uiautomator/init.py", line 432, in wrapper return _method_obj(_args, *_kwargs) File "/usr/local/lib/python2.7/dist-packages/uiautomator/init.py", line 131, in call "%s: %s" % (jsonresult["error"]["data"]["exceptionTypeName"], jsonresult["error"]["message"]) uiautomator.JsonRPCError: JsonRPC Error code: 0, Message: java.lang.IllegalStateException: UiAutomationService not connected. Did you call #register()?

chicharitomu14 commented 7 years ago

OK, the error is solved temporary. I have changed the timeout parameter in the init.py file.

yifeikong commented 7 years ago

It seems that adb connection is very unstable, however, uiautomator depends on that to work. Almost all connection errors are caused by that, I'm planning rewrite a version based on ssh connections.

chicharitomu14 commented 7 years ago

Well, great idea.

picket-001 commented 7 years ago

@yifeikong @chicharitomu14 have you tried resolving the above problem?

yifeikong commented 7 years ago

@KD-MAT I have tried, but failed. It seems that this is a problem with the architecture that uiautomator is using. To communicate with android, UiAutomator pushes an apk to android(only on first run), and then use command line to start a rpc server on android, and then connects to the rpc server using adb port forwarding. None of the mentioned steps is reliable for a long-run communication. So, to fix this, there needs a total reconstruction of the tool.