Open mayujsw opened 10 years ago
Could you please run below command?
$ curl -d '{"jsonrpc":"2.0","method":"ping","id":"1234"}' -H 'Content-type: application/json' http://localhost:9008/jsonrpc/0
If the output is {"jsonrpc":"2.0","id":"1234","result":"pong"}
, the server is ok, else the server is not up.
hi xiaocong,
Thanks much for your quick reply, but we still met error as below for your command: HOST$curl -d '{"jsonrpc":"2.0","method":"ping","id":"1234"}' -H 'Content-type: application/json' http://localhost:9008/jsonrpc/0 curl: (52) Empty reply from server
and here is the output on the android device my@mm:~/Documents/L/out/host/linux-x86/bin$ ./adb shell root@device:/ # uiautomator runtest bundle.jar uiautomator-stub.jar -c com.g> INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: stream= com.github.uiautomatorstub.Stub: INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner INSTRUMENTATION_STATUS: test=testUIAutomatorStub INSTRUMENTATION_STATUS: class=com.github.uiautomatorstub.Stub INSTRUMENTATION_STATUS: current=1 INSTRUMENTATION_STATUS_CODE: 1 INSTRUMENTATION_RESULT: shortMsg=java.lang.Error INSTRUMENTATION_RESULT: longMsg=java.io.IOException: open failed: ENOENT (No such file or directory) INSTRUMENTATION_CODE: 0
we tried on Nexus7 with android L, not sure whether anyone make it workable now ...
I can reproduce it. Likely NanoHttpd failed to open temp file. I am looking at it. Thank you.
Great to know, thanks :)
Please update to v0.1.32 and check if it's fixed. Thx
Thanks for your quick update, we'll give a try tomorrow morning :)
It's OK now, thanks xiaocong !
after we do adb reboot, it can not work anymore, reporting "Connection reset by peer" as below
server.pressKey("home") Traceback (most recent call last): File "
", line 1, in File "/usr/local/lib/python2.7/dist-packages/jsonrpclib/jsonrpc.py", line 274, in call return self.send(self.name, args) File "/usr/local/lib/python2.7/dist-packages/jsonrpclib/jsonrpc.py", line 224, in _request response = self._run_request(request) File "/usr/local/lib/python2.7/dist-packages/jsonrpclib/jsonrpc.py", line 242, in _run_request verbose=self.__verbose File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request return self.single_request(host, handler, request_body, verbose) File "/usr/lib/python2.7/xmlrpclib.py", line 1294, in single_request response = h.getresponse(buffering=True) File "/usr/lib/python2.7/httplib.py", line 1030, in getresponse response.begin() File "/usr/lib/python2.7/httplib.py", line 407, in begin version, status, reason = self._read_status() File "/usr/lib/python2.7/httplib.py", line 365, in _read_status line = self.fp.readline() File "/usr/lib/python2.7/socket.py", line 447, in readline data = self._sock.recv(self._rbufsize) socket.error: [Errno 104] Connection reset by peer
Could you please capture device logcat? Thank you.
OK, wait for a min
D/AndroidRuntime( 5451): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 5451): CheckJNI is OFF
E/memtrack( 5451): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 5451): failed to load memtrack module: -2
V/Fingerprint-JNI( 5451): FingerprintManager JNI ready.
D/AndroidRuntime( 5451): Calling main entry com.android.commands.uiautomator.Launcher
I/wpa_supplicant( 3936): wlan0: CTRL-EVENT-SCAN-STARTED
I/wpa_supplicant( 3936): wlan0: CTRL-EVENT-SCAN-STARTED
E/UiAutomatorTestRunner( 5451): uncaught exception
E/UiAutomatorTestRunner( 5451): java.lang.Error: java.io.IOException: open failed: ENOENT (No such file or directory)
E/UiAutomatorTestRunner( 5451): at fi.iki.elonen.NanoHTTPD$HTTPSession.getTmpBucket(NanoHTTPD.java:1238)
E/UiAutomatorTestRunner( 5451): at fi.iki.elonen.NanoHTTPD$HTTPSession.parseBody(NanoHTTPD.java:952)
E/UiAutomatorTestRunner( 5451): at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:288)
E/UiAutomatorTestRunner( 5451): at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:920)
E/UiAutomatorTestRunner( 5451): at fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:175)
E/UiAutomatorTestRunner( 5451): at java.lang.Thread.run(Thread.java:818)
E/UiAutomatorTestRunner( 5451): Caused by: java.io.IOException: open failed: ENOENT (No such file or directory)
E/UiAutomatorTestRunner( 5451): at java.io.File.createNewFile(File.java:941)
E/UiAutomatorTestRunner( 5451): at java.io.File.createTempFile(File.java:1006)
E/UiAutomatorTestRunner( 5451): at fi.iki.elonen.NanoHTTPD$DefaultTempFile.
and we find that each time we reboot the android, it could only work again after we re-push the 2 jar files, and re-run "adb shell uiautomator runtest bundle.jar uiautomator-stub.jar -c com.github.uiautomatorstub.Stub" . While on KitKat, we do not need these step, uiautomator can be always workable no matter reboot or not...
Very strange... Python wrapper should have done all the same steps automatically. Please help double check if the uiautomator's version in your working environment is 0.1.32.
yes, we download from here : https://pypi.python.org/pypi/uiautomator/0.1.32
From usage perspective, the difference vs. KitKat now is that we need to push 2 JAR files/run these 2 jar through uiautomator everytime we boot up android ..
Just tried on Nexus7 Android L, also met connect reset by peer error
logcat please.
The first time, it works as below :
d.info {u'displayRotation': 1, u'displaySizeDpY': 600, u'displaySizeDpX': 960, u'displayWidth': 1920, u'productName': u'razor', u'currentPackageName': u'com.android.launcher', u'sdkInt': 20, u'displayHeight': 1104, u'naturalOrientation': False}
Then we reboot, try again, it does not work anymore, logcat is attached below as well:
d.info Traceback (most recent call last): File "
", line 1, in File "/usr/local/lib/python2.7/dist-packages/uiautomator/init.py", line 519, in info return self.server.jsonrpc.deviceInfo() File "/usr/local/lib/python2.7/dist-packages/uiautomator/init.py", line 400, in wrapper server.start() File "/usr/local/lib/python2.7/dist-packages/uiautomator/init.py", line 440, in start raise IOError("RPC server not started!") IOError: RPC server not started!
logcat:
the change in 0.1.32 version of below codes may lead to fail to push jar package to mobile. I remove this change and the server will be ok
cmd_line = ["-s", "'%s'" % self.device_serial()] + list(args)
return dict([s.split() for s in out[index + len(match):].strip().splitlines() if s.strip()])
Thank @henrydeng. Do you know how it fails?
we met badstatusline error when trying uiautomator 1.4:
per the UIautomatior v1.4 steps: Run the jsonrcp server on Android device
How to use
Next is a python example using jsonrpclib. Before you run it, make sure install jsonrpclib via
pip install jsonrpclib
.