2013-10-06 29 views
1

舉杯我使用SL4A只寫了在Python這3條線:SL4A蟒蛇作出android手機

import android 
    droid = android.Android() 
    droid.makeToast(u"ascc4r") 

運行此代碼時,我得到以下錯誤:

pydev debugger: starting 
Traceback (most recent call last): 
    File "C:\Users\Tibi\Desktop\adt-bundle-windows-x86_64-20130917\eclipse\plugins  \org.python.pydev_2.8.2.2013090511\pysrc\pydevd.py", line 1446, in <module> 
    debugger.run(setup['file'], None, None) 
    File "C:\Users\Tibi\Desktop\adt-bundle-windows-x86_64-20130917\eclipse\plugins org.python.pydev_2.8.2.2013090511\pysrc\pydevd.py", line 1092, in run 
    pydev_imports.execfile(file, globals, locals) #execute the script 
    File "C:\Users\Tibi\workspace\26\src\26module.py", line 7, in <module> 
    droid = android.Android() 
    File "C:\Python26\lib\android.py", line 34, in __init__ 
    self.conn = socket.create_connection(addr) 
    File "C:\Python26\lib\socket.py", line 547, in create_connection 
    for res in getaddrinfo(host, port, 0, SOCK_STREAM): 
socket.gaierror: [Errno 11001] getaddrinfo failed 

環境設置: - Python 2.6.6 - set ap_port = 9999 - adb forward tcp:9999 tcp:xxxx(xxxx,我在電話上啓動服務器) 我的android.py位於Python/Lib文件夾中。

更新: 我嘗試了CMD中的這3個指令,它的工作,使吐司。所以我認爲這個錯誤出現在ADT包或Eclipse Python插件中。

什麼是Errno 11001?

+0

嘗試使用SL4A模塊代替(進口SL4A) 。 – pinogun

回答

2

What is this Errno 11001?

我不知道有關的錯誤,但我建議使用正確的語法,這是

import android 
droid = android.Android() 
droid.makeToast('my text to print should be inside the quotes') 

又見API Overview