Buildozer requests ConnectionError

149 views
Skip to first unread message

Ish Rash

unread,
Jan 4, 2019, 4:12:06 AM1/4/19
to Kivy users support
My goal is to get song lyrics with PyLyrics
r = requests.get('http://lyrics.wikia.com/{0}:{1}'.format(singer,song))
works on kivy launcher but fails when I compile the app with buildozer.

buildozer requirements: hostpython2,python2,kivy,android,requests,openssl,pyasn1,ndg_httpsclient,beautifulsoup4,,html5lib

permissions: INTERNET

Error:

01-03 12:39:18.807 23149 23167 I python : File "/home/kivy/Desktop/LyricsFind/.buildozer/android/app/main.py", line 3003, in get_lyrics 01-03 12:39:18.807 23149 23167 I python : File "/home/kivy/Desktop/LyricsFind/.buildozer/android/app/PyLyrics/functions.py", line 99, in getLyrics 01-03 12:39:18.817 23149 23167 I python : File "/home/kivy/Desktop/LyricsFind/.buildozer/android/platform/build/dists/LyricsFind/private/lib/python2.7/site-packages/requests/api.py", line 70, in get 01-03 12:39:18.817 23149 23167 I python : File "/home/kivy/Desktop/LyricsFind/.buildozer/android/platform/build/dists/LyricsFind/private/lib/python2.7/site-packages/requests/api.py", line 56, in request 01-03 12:39:18.817 23149 23167 I python : File "/home/kivy/Desktop/LyricsFind/.buildozer/android/platform/build/dists/LyricsFind/private/lib/python2.7/site-packages/requests/sessions.py", line 488, in request 01-03 12:39:18.817 23149 23167 I python : File "/home/kivy/Desktop/LyricsFind/.buildozer/android/platform/build/dists/LyricsFind/private/lib/python2.7/site-packages/requests/sessions.py", line 609, in send 01-03 12:39:18.817 23149 23167 I python : File "/home/kivy/Desktop/LyricsFind/.buildozer/android/platform/build/dists/LyricsFind/private/lib/python2.7/site-packages/requests/adapters.py", line 487, in send 01-03 12:39:18.817 23149 23167 I python : requests.exceptions.ConnectionError: HTTPConnectionPool(host='lyrics.wikia.com', port=80): Max retries exceeded with url: /lil_wayne:lollipop (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x904138b0>: Failed to establish a new connection: [Errno 2] temporary failure in name resolution.',))

python
for android ended

I have tried catch the error and try again with sleep but nothing is work. Any help will be appreciated. Thank you!

ZenCODE

unread,
Jan 4, 2019, 12:10:25 PM1/4/19
to Kivy users support
Is the app able to access other URL's? Or does it fail for all? "Temporary failure in name resolution" would tend to suggest a DNS issue. Try testing with the "lyrics.wikia.com" replaced with the actual IP address?

Ish Rash

unread,
Jan 4, 2019, 12:15:10 PM1/4/19
to Kivy users support
Its fails to access all urls.

ZenCODE

unread,
Jan 4, 2019, 3:11:44 PM1/4/19
to Kivy users support
And using the IP's?

Ish Rash

unread,
Jan 4, 2019, 4:20:00 PM1/4/19
to Kivy users support
I got 151.101.0.194 with python's socket.gethostbyname('lyrics.wikia.com'), but that doesn't work.

Ish Rash

unread,
Jan 4, 2019, 4:26:48 PM1/4/19
to Kivy users support
[WARNING           ] stderr:   File "/storage/emulated/0/kivy/LyricsFind/PyLyrics/functions.py", line 105, in getLyrics
[WARNING           ] stderr:     r = requests.get(ip+'/{0}:{1}'.format(singer,song))
[WARNING           ] stderr:   File "/storage/emulated/0/kivy/LyricsFind/requests/api.py", line 70, in get
[WARNING           ] stderr:     return request('get', url, params=params, **kwargs)
[WARNING           ] stderr:   File "/storage/emulated/0/kivy/LyricsFind/requests/api.py", line 56, in request
[WARNING           ] stderr:     return session.request(method=method, url=url, **kwargs)
[WARNING           ] stderr:   File "/storage/emulated/0/kivy/LyricsFind/requests/sessions.py", line 488, in request
[WARNING           ] stderr:     resp = self.send(prep, **send_kwargs)
[WARNING           ] stderr:   File "/storage/emulated/0/kivy/LyricsFind/requests/sessions.py", line 603, in send
[WARNING           ] stderr:     adapter = self.get_adapter(url=request.url)
[WARNING           ] stderr:   File "/storage/emulated/0/kivy/LyricsFind/requests/sessions.py", line 685, in get_adapter
[WARNING           ] stderr:     raise InvalidSchema("No connection adapters were found for '%s'" % url)
[WARNING           ] stderr: requests.exceptions.InvalidSchema: No connection adapters were found for '151.101.0.194/lil_wayne:lollipop'

Ish Rash

unread,
Jan 4, 2019, 4:37:25 PM1/4/19
to Kivy users support
"Song or Singer does not exist or the API does not have Lyrics" ValueError is raised with this: 'http://151.101.0.194'

ZenCODE

unread,
Jan 4, 2019, 5:15:10 PM1/4/19
to Kivy users support
Okay, so then you know it's almost certainly a DNS issue. How is your device connected? What are it's DNS settings? Or what is the router it's connected to using for DNS? Are you behind some kind of firewall or proxy? Try testing on another network?
Message has been deleted

Ish Rash

unread,
Jan 5, 2019, 10:49:53 AM1/5/19
to Kivy users support
I'm new to python but I'm sorry, I don't think it is a DNS issue.

I compiled the app with these changes in buildozer.spec and it works perfectly:

py3
kivy complete 
1st version
requirements 
= python3crystax==3.5, kivy==1.10.1, plyer, android, pyopenssl, requests, beautifulsoup4, html5lib
android
.api = 19
android
.minapi = 19
android
.sdk = 23
android
.ndk_path = /home/kivy/Android/crystax-ndk-10.3.2/

py2
kivy complete 
0.5
requirements 
= python2, kivy==1.10.1, plyer, android, openssl, requests, beautifulsoup4, html5lib
android
.api = 19
android
.minapi = 19
android
.sdk = 23
android
.ndk = 17c

py2
-old toolchain
requirements 
= python2, kivy, plyer, android, openssl, requests, beautifulsoup4, html5lib
android
.api = 19
android
.minapi = 19
android
.sdk = 20
android
.ndk = 10e


The only time I get the ConnectionError, is when I compile with api 27 or 28, minapi=21

I follow these instructions to handle runtime permission for INTERNET 

Also I tried to run urllib.urlopen('https://www.google.com'). I get 
IOError: [Errno socket error] [Errno 2] temporary failure in name resolution

with api 27. I attached the log. All the other permissions work but not internet.

Thanks!!!
urllib traceback.txt

ZenCODE

unread,
Jan 5, 2019, 12:05:53 PM1/5/19
to Kivy users support
Yes, then it's almost certainly a permission issue with the new API level. You will then need to check and request these permissions as outlined in the android documentation....

Ish Rash

unread,
Jan 5, 2019, 12:20:46 PM1/5/19
to Kivy users support
I just did with @T.Kuam's steps and its still giving me the same errors with both PyLyrics and urllib.urlopen

Ish Rash

unread,
Jan 5, 2019, 12:30:17 PM1/5/19
to Kivy users support
The only thing I changed the gradle version from those steps, mine is v.3.1.2
Message has been deleted

Ish Rash

unread,
Jan 5, 2019, 1:21:01 PM1/5/19
to Kivy users support
buildozer traceback.txt

Ish Rash

unread,
Jan 9, 2019, 11:29:55 PM1/9/19
to Kivy users support
Solved it by adding INTERNET to my buildozer.spec permissions and lxml to the requirements

adding this code before from importing bs4 solved the htmlparser error: source
import imp
import sys


class ImportBlocker(object):


   
def __init__(self, *args):
       
self.black_list = args


   
def find_module(self, name, path=None):
       
if name in self.black_list:
           
return self


       
return None


   
def load_module(self, name):
       
module = imp.new_module(name)
       
module.__all__ = [] # Necessary because of how bs4 inspects the module


       
return module


sys
.meta_path = [ImportBlocker('bs4.builder._htmlparser')]

and 
buildozer android clean


Reply all
Reply to author
Forward
0 new messages