Hi, I have developed a simple app with a single button which, when clicked, updates some data in a MySQL database a remote server. The app is working fine when run from my Ubuntu 18.0.4 desktop but it doesn't work on Android. The apk is getting compiled and installed and the app launches without an issue. When I click on the button to start the database connection, the whole app crashes and the operation is not performed.
Following is my code:
import kivy
from kivy.uix.button import Button
import mysql.connector
from android.permissions import request_permissions, Permission
def upload_files(*args):
mydb = mysql.connector.connect(host="XXX.XXX.XXX.XXX",user="XXXXX",password="XXXXXXXXXXXX",database="XXXX", ssl_ca='ssl-client/ca.pem', ssl_cert='ssl-client/client-cert.pem', ssl_key='ssl-client/client-key.pem')
mycursor = mydb.cursor(buffered=True)
sql1="SELECT * from images"
val1=()
mycursor.execute(sql1,val1)
sl_no=mycursor.rowcount
sl_no=sl_no+1
with open('icons8-address-book-96.png', 'rb') as f:
binaryData = f.read()
sql2="INSERT INTO images(serial_no, file_name, media) VALUES(%s, %s, %s)"
val2=(sl_no,'/var/sftp/sivamediassh/icons8-address-book-96.png',binaryData)
mycursor.execute(sql2,val2)
mydb.commit()
mycursor.close()
mydb.close()
class MyApp(App):
def build(self):
request_permissions([Permission.READ_EXTERNAL_STORAGE,Permission.WRITE_EXTERNAL_STORAGE])
btn1=Button(text='Upload',size_hint_x=0.2,size_hint_y=0.2, pos=(100,100))
btn1.bind(on_release=upload_files)
return btn1
if __name__=='__main__':
MyApp().run()
The Buildozer requirements are as follows:
requirements = python3,kivy,mysql_connector
The Buildozer permissions are as follows:
android.permissions = INTERNET,READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE
The logcat error is as follows:
12-19 23:57:02.050 26563 26563 W System.err: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
12-19 23:57:02.051 26563 26563 W System.err: at libcore.io.Linux.open(Native Method)
12-19 23:57:02.051 26563 26563 W System.err: at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
12-19 23:57:02.051 26563 26563 W System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
Could you please advise what I am doing wrong?
Thanks