Kivy: AsyncImage and Urllib wont open ANY url on Android

Viewed 859

I recently started targeting android with some programs i had already written in kivy on my pc, but after building and installing on my phone I have discovered that urllib doesn't seem to accept ANY url i feed to it despite the fact that it works perfectly on my pc. In Addition, any kivy widget that makes use of urllib to connect to the internet fails in the exact same way.

Here's some example code:

from kivy.app import App
from kivy.uix.image import AsyncImage

class TestApp(App):
    def build(self):
        return AsyncImage(source="http://kivy.org/logos/kivy-logo-black-64.png")

TestApp().run()

When the app is run, this appears in logcat:

11-07 15:50:10.400  3741  4686 I python  : [INFO   ] [GL          ] 
Using the "OpenGL ES 2" graphics system
11-07 15:50:10.400  3741  4686 I python  : [INFO   ] [GL          ] 
Backend used <gl>
11-07 15:50:10.410  3741  4686 I python  : [INFO   ] [GL          ] 
OpenGL version <b'OpenGL ES 3.1 V@140.0 (GIT@Ifd751822f5)'>
11-07 15:50:10.410  3741  4686 I python  : [INFO   ] [GL          ] 
OpenGL vendor <b'Qualcomm'>
11-07 15:50:10.410  3741  4686 I python  : [INFO   ] [GL          ] 
OpenGL renderer <b'Adreno (TM) 420'>
11-07 15:50:10.410  3741  4686 I python  : [INFO   ] [GL          ] 
OpenGL parsed version: 3, 1
11-07 15:50:10.410  3741  4686 I python  : [INFO   ] [GL          ] 
Texture max size <16384>
11-07 15:50:10.410  3741  4686 I python  : [INFO   ] [GL          ] 
Texture max units <16>
11-07 15:50:10.470  3741  4686 I python  : [INFO   ] [Window      ] 
auto add sdl2 input provider
11-07 15:50:10.470  3741  4686 I python  : [INFO   ] [Window      ] 
virtual keyboard not allowed, single mode, not docked
11-07 15:50:10.550  3741  4686 I python  : [INFO   ] [Loader      ] 
using a thread pool of 2 workers
11-07 15:50:10.720  3741  4686 I python  : [WARNING] [Base        ] 
Unknown <android> provider
11-07 15:50:10.720  3741  4686 I python  : [INFO   ] [Base        ] Start application main loop
11-07 15:50:10.740  3741  4686 I python  : [ERROR  ] [Base        ] Failed to import "android" module. Could not remove android presplash.
11-07 15:50:12.130  3741  4943 I python  : [ERROR  ] [Loader      ] Failed to load image <http://kivy.org/logos/kivy-logo-black-64.png>
11-07 15:50:12.130  3741  4943 I python  : Traceback (most recent call last):
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/site-packages/kivy/loader.py", line 317, in _load_urllib
11-07 15:50:12.130  3741  4943 I python  :     fd = urllib_request.urlopen(filename)
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/stdlib.zip/urllib/request.py", line 162, in urlopen
11-07 15:50:12.130  3741  4943 I python  :     return opener.open(url, data, timeout)
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/stdlib.zip/urllib/request.py", line 471, in open
11-07 15:50:12.130  3741  4943 I python  :     response = meth(req, response)
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/stdlib.zip/urllib/request.py", line 581, in http_response
11-07 15:50:12.130  3741  4943 I python  :     'http', request, response, code, msg, hdrs)
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/stdlib.zip/urllib/request.py", line 503, in error
11-07 15:50:12.130  3741  4943 I python  :     result = self._call_chain(*args)
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/stdlib.zip/urllib/request.py", line 443, in _call_chain
11-07 15:50:12.130  3741  4943 I python  :     result = func(*args)
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/stdlib.zip/urllib/request.py", line 686, in http_error_302
11-07 15:50:12.130  3741  4943 I python  :     return self.parent.open(new, timeout=req.timeout)
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/stdlib.zip/urllib/request.py", line 465, in open
11-07 15:50:12.130  3741  4943 I python  :     response = self._open(req, data)
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/stdlib.zip/urllib/request.py", line 488, in _open
11-07 15:50:12.130  3741  4943 I python  :     'unknown_open', req)
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/stdlib.zip/urllib/request.py", line 443, in _call_chain
11-07 15:50:12.130  3741  4943 I python  :     result = func(*args)
11-07 15:50:12.130  3741  4943 I python  :   File "/data/user/0/org.lgt.lgt/files/app/crystax_python/stdlib.zip/urllib/request.py", line 1310, in unknown_open
11-07 15:50:12.130  3741  4943 I python  :     raise URLError('unknown url type: %s' % type)
11-07 15:50:12.130  3741  4943 I python  : urllib.error.URLError: <urlopen error unknown url type: https>

This is a very strange error to me because the url I submitted is http and not https

Here's my buildozer spec file link

1 Answers

Url you trying to load (http://kivy.org/logos/kivy-logo-black-64.png) redirects on url with https protocol (just load it in browser to see).

To load urls with https on Android you should build your apk with OpenSSL support.

On Python 2 it can be achieved with adding openssl in buildozer's requirements.

I'm not sure if it'll work with python3crystax.

Related