简体   繁体   English

无法连接到SL4A服务器

[英]Unable to connect to SL4A server

I'm unable to connect to the Android Scripting layer server. 我无法连接到Android脚本层服务器。 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. 我已采取的步骤:1.设置adb转发。 2. Made available the Android.py file to the interpreter. 2.将Android.py文件提供给解释器。 3. Started a private server and connected the device to the computer. 3.启动专用服务器并将设备连接到计算机。

What could be wrong? 有什么事吗

Did you export the "AP_PORT" environment variable? 您是否导出了“ AP_PORT”环境变量?

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: 您需要在进入python解释器之前设置AP_PORT,如下所示:

$ export AP_PORT=9999

I have a script that sets the environment up and starts the python interpreter here: 我有一个脚本来设置环境并在此处启动python解释器:

https://github.com/georgegoh/Android-Scripting/blob/master/py4a_start.sh https://github.com/georgegoh/Android-Scripting/blob/master/py4a_start.sh

I've only tested and used it on Ubuntu, so YMMV. 我只在Ubuntu上测试和使用过它,所以是YMMV。

Environment: Eclipse with the pydev plugin and Android developement in Linux. 环境:带有pydev插件的Eclipse和Linux中的Android开发。

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. 如果即使在执行George Goh解决方案后仍然出现相同的问题,那么请使用Eclipse的解释器设置将环境变量的值传递为AP_PORT=9999

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM