Search code examples
androidpythonkivypymysqlbuildozer

Python Buildozer PyMySQL Cant Connect


I have created a application inside kivy using the pymysql module to create a simple log in system. The python file runs without errors on my desktop, but when I run the app on my Nexus tablet it crashes and throws following errors.

Can someone identify the cause of this issue and point me in the right direction? Thanks.

06-07 12:07:35.319 10766 10786 I python  :  Traceback (most recent call     last):
06-07 12:07:35.342 10766 10786 I python  :    File "/home/andrew/Desktop/Python/Kivy/1-application/.buildozer/android/app/main.py", line 83, in <module>
06-07 12:07:35.343 10766 10786 I python  :    File "/home/andrew/Desktop/Python/Kivy/1-application/.buildozer/android/platform/build/dists/myapp/private/lib/python2.7/site-packages/pymysql/__init__.py", line 90, in Connect
06-07 12:07:35.344 10766 10786 I python  :    File "/home/andrew/Desktop/Python/Kivy/1-application/.buildozer/android/platform/build/dists/myapp/private/lib/python2.7/site-packages/pymysql/connections.py", line 706, in __init__
06-07 12:07:35.345 10766 10786 I python  :    File "/home/andrew/Desktop/Python/Kivy/1-application/.buildozer/android/platform/build/dists/myapp/private/lib/python2.7/site-packages/pymysql/connections.py", line 963, in connect
06-07 12:07:35.346 10766 10786 I python  :  pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '<IP ADDRESS>' ([Errno 13] Permission denied)")
06-07 12:07:35.402 10766 10786 I python  : Python for android ended.

EDIT: I went into the buildozer.spec file and uncommented the permission for internet access now im getting a timeout error.

pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '<IP ADDRESS>' (timed out)")

Here is a sample of how I am trying to connect to my db...

from kivy.app import App
from kivy.uix.gridlayout import GridLayout
import pymysql.cursors

class LoginScreen(GridLayout):
    #CONTENT HERE

class SimpleKivy(App):
    def build(self):
        return LoginScreen()

if __name__ == "__main__":
    #Error Happens Here
    connection = pymysql.connect(host="<IP ADDRESS>", user="usr", password="pswd", db="slogin")

    SimpleKivy().run()

Solution

  • Fixed. Firewall was blocking access to MYSQL server and the error without exception handling caused the application to crash.