Reputation: 16154
I'm unable to connect to the Android Scripting layer server. When I run the command I get the following error:
> >>> a = android.Android() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "android.py", line 34, in
> __init__
> self.conn = socket.create_connection(addr) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py",
> line 553, in create_connection
> for res in getaddrinfo(host, port, 0, SOCK_STREAM): socket.gaierror: [Errno 8] nodename nor servname provided, or not
> known
Steps that I've taken: 1. setup adb forwarding. 2. Made available the Android.py file to the interpreter. 3. Started a private server and connected the device to the computer.
What could be wrong?
Upvotes: 0
Views: 1895
Reputation: 313
Environment: Eclipse with the pydev plugin and Android developement in Linux.
If the same problem arises even after doing George Goh's solution, then pass the environment variable with the value as AP_PORT=9999
using the interpreter setting of Eclipse.
Upvotes: 0
Reputation: 46
Did you export the "AP_PORT" environment variable?
It should be set to the port forwarded to.
For example, if you set the forwarding port like this:
$ adb forward tcp:9999 tcp:{SL4A port}
You need to set the AP_PORT before entering the python interpreter, like this:
$ export AP_PORT=9999
I have a script that sets the environment up and starts the python interpreter here:
https://github.com/georgegoh/Android-Scripting/blob/master/py4a_start.sh
I've only tested and used it on Ubuntu, so YMMV.
Upvotes: 3