How to start sl4a server on android from terminal and connect to it with python?

546 views Asked by At

I'm installed qpython app to my phone. From the app I can run scripts with androidhelper but if I run qpython from terminal and try to create an Android object it has been refused.

$ pwd
/data/user/0/org.qpython.qpy/files/bin
$ ./qpython-android5.sh
Python 2.7.15 (qpyc:2.7.15, Aug 22 2018, 06:50:49) [BUILD WITH QPY-TOOLCHAIN (https://github.com/qpython-android) ] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import androidhelper
>>> driod=androidhelper.Android()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/user/0/org.qpython.qpy/files/lib/python2.7/qpyutil.zip/androidhelper/sl4a.py", line 34, in __init__
  File "/data/user/0/org.qpython.qpy/files/lib/python27.zip/socket.py", line 575, in create_connection
socket.error: [Errno 111] Connection refused

Can I start somehow the server by myself and config qpython to be able to connect to it?

Thanks!

1

There are 1 answers

1
james beastly On

I think that if your running into this problem you should first check that your s4la server is running by going to more and then checking the s4la server box so you know the s4la server is running

If it still doesn't work unchecked and recheck the box but you have to realize with using the

droid = androidhelper.Android()

Command that sometimes it'll work and sometimes it won't.

So if after doing what I said with the box if it doesn't work just wait a few hours and try again.