Simple App (SFTP using Paramiko) doesn't work on Android.

838 views
Skip to first unread message

alanq...@gmail.com

unread,
Jun 21, 2015, 7:13:51 AM6/21/15
to kivy-...@googlegroups.com
Hello there.

I've made a simple app just for testing and it runs fine on desktop but it crashes with the following error on android:
socket.gaierror: [Errno 4] non-recoverable failure in name resolution.
(NOTE: The error is triggered on line 16)

The entire app code is below:
import kivy
import paramiko
kivy
.require('1.0.6')

__version__
= '0.1'

from kivy.app import App
from kivy.uix.label import Label

class TestSt(App):
   
   
def build(self):
       
        ssh
= paramiko.SSHClient()
        ssh
.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh
.connect("test.rebex.net", 22, "demo", "password")
       
        ftp
= ssh.open_sftp()
       
        filesstr
= "REMOTE FILES: "
       
       
for rf in ftp.listdir():
            filesstr
+=rf+"; "
       
       
return Label(text=filesstr)

if __name__ in ('__main__', '__android__'):
   
TestSt().run()
The apk builds without errors.

Thank you in advance.

alanq...@gmail.com

unread,
Jun 21, 2015, 11:14:35 AM6/21/15
to kivy-...@googlegroups.com
Here is the full logcat (adb logcat -s python):

--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
V/python  (  817): metadata fullscreen is1
I/python  (  817): Starting audio thread
I/python  (  817): Initialize Python for Android
I/python  (  817): ['/data/data/org.test.mydevapp/files/lib/python2.7/site-packages', '/data/data/org.test.mydevapp/files/lib/site-python']
I/python  (  817): Android path ['/data/data/org.test.mydevapp/files/lib/python27.zip', '/data/data/org.test.mydevapp/files/lib/python2.7', '/data/data/org.test.mydevapp/files/lib/python2.7/lib-dynload', '/data/data/org.test.mydevapp/files/lib/python2.7/site-packages', '/data/data/org.test.mydevapp/files', '/data/data/org.test.mydevapp/files/_applibs']
I/python  (  817): Android kivy bootstrap done. __name__ is __main__
I/python  (  817): Run user program, change dir and execute main.py
I/python  (  817): [INFO              ] [Logger      ] Record log in /data/data/org.test.mydevapp/files/.kivy/logs/kivy_15-06-21_1.txt
I/python  (  817): [INFO              ] [Kivy        ] v1.9.0
I/python  (  817): [INFO              ] [Python      ] v2.7.2 (default, Jun 21 2
015, 05:54:23)
I/python  (  817): [GCC 4.8]
I/python  (  817): [INFO              ] [Factory     ] 173 symbols loaded
I/python  (  817):  /data/data/org.test.mydevapp/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:13: RuntimeWarning: import cdrom: No module named cdrom
I/python  (  817):  (ImportError: No module named cdrom)
I/python  (  817): [INFO              ] [Image       ] Providers: img_tex, img_dds, img_gif, img_pygame (img_pil, img_ffpyplayer ignored)
I/python  (  817): [INFO              ] [Text        ] Provider: pygame
I/python  (  817):  Traceback (most recent call last):
I/python  (  817):    File "/home/kivy/Kivy_VM_CP/.buildozer/android/app/main.py", line 28, in <module>
I/python  (  817):    File "/home/kivy/Kivy_VM_CP/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/app.py", line 798, in run
I/python  (  817):    File "/home/kivy/Kivy_VM_CP/.buildozer/android/app/main.py", line 16, in build
I/python  (  817):    File "/home/kivy/Kivy_VM_CP/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/paramiko/client.py", line 286, in connect
I/python  (  817):  socket.gaierror: [Errno 4] non-recoverable failure in name resolution.
I/python  (  817): Python for android ended.

alanq...@gmail.com

unread,
Jun 21, 2015, 1:59:26 PM6/21/15
to kivy-...@googlegroups.com
Hey guys, the problem was the android permissions... the default buildozer permissions line is commented out and I didn't notice that because of the lack of syntax highlighter (so it's not my fault *insert whistling smilie here*).


On Sunday, June 21, 2015 at 8:13:51 AM UTC-3, alanq...@gmail.com wrote:

alanq...@gmail.com

unread,
Jun 21, 2015, 6:15:11 PM6/21/15
to kivy-...@googlegroups.com
I forgot to thank inclement from the IRC channel for pointing that out. Sorry and thank you inclement.

João Paulo Saboia

unread,
May 17, 2016, 8:35:54 PM5/17/16
to Kivy users support
I have the same problem I guess. Paramiko works on PC but not on Android and the APK is built without problem. What did you do on permissions?
I'm using this:

# (list) Permissions
android.permissions = CAMERA

Was this line you changed on buildozer.spec? What should I add?

João Paulo Saboia

unread,
May 18, 2016, 10:16:31 AM5/18/16
to Kivy users support
My problem was ecdsa.
Maybe this can help somebody, I added ecdsa on requirements. More information on: http://stackoverflow.com/questions/37288235/using-paramiko-on-a-android-python-app/37302083#37302083
Reply all
Reply to author
Forward
0 new messages