Sending data from app to live database working on desktop but not in mobile.

38 views
Skip to first unread message

mahmud al hasan

unread,
Jun 20, 2018, 6:15:22 AM6/20/18
to kivy-...@googlegroups.com
I have created a signup app using kivy where I am sending data to live mysql database. The app works on desktop but not working after I created apk and crash every time. I have failed to connect database from android app. 

Now I want to know -

1. Is there any problem with my app?
2. What should be the requirements for buildozer.spec file for my app?
3. Should I need to add anything to connect the app with live database?

I have attached my project file where I used rest api to connect with my server. Feel free to look at those and upload buildozer.spec file for the app if necessary.



signup.py
from kivy.uix.boxlayout import BoxLayout
import requests, json, urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

class SignupPage(BoxLayout):
    def signup(self):
        username, password = self.ids.username.text, self.ids.password.text
        info = {
            "signup": [
                {
                    "username": username,
                    "password": password
                }
            ]
        }

        # headers = {"Content-type": "application/json"}
        resp = requests.post(url, data=dict(info=json.dumps(info)), verify=False)
        if resp:
            if  username and password:
                print('Data successfully saved!')
            else:
                print('Please enter user name and password!')




signup.kv
<SignupPage>:
    orientation: 'vertical'
    Label:
        text: 'Welcome to tima SignUp page'
        font_size: 30

    GridLayout:
        orientation: 'vertical'
        cols: 2
        padding: 5
        spacing: 5
        row_force_default: True
        row_default_height: 40
        size_hint_x: 1
        size_hint_y: 1
        Label:
            text: 'User Name:'
            size_hint_x: None
            width: 100
        TextInput:
            id: username
            multiline: False
        Label:
            text: 'Password'
            size_hint_x: None
            width: 100
        TextInput:
            id: password
            multiline: False
            password: True # hide password
        Label:
            text: ''
            size_hint_x: None
            width: 100
        Button:
            text: "SignUp"
            size_hint_x: None
            width: 100
            on_release: root.signup()




main.py
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang.builder import Builder
from signup.signup import SignupPage


Builder.load_file('signup/signup.kv')


class RootWidget(BoxLayout):
    pass


class MainApp(App):
    def build(self):
        return SignupPage()


if __name__ == '__main__':
    MainApp().run()



main.kv
BoxLayout:
    size_hint: .5,.5
    pos: 200,200
    name: "user"
    Button:
        text: "back"
        on_release: app.root.current = "login_page"


kivy-signup.zip

ZenCODE

unread,
Jun 21, 2018, 10:28:46 AM6/21/18
to Kivy users support
Have you added internet permissions for android in your requirements? You will also need openssl as it's a HTTPS request....

mahmud al hasan

unread,
Jun 22, 2018, 12:18:47 AM6/22/18
to kivy-...@googlegroups.com


On Thursday, June 21, 2018 at 8:28:46 PM UTC+6, ZenCODE wrote:
Have you added internet permissions for android in your requirements? You will also need openssl as it's a HTTPS request....



Yes, I have added internet permission for android in requirements and I have attached the buildozer.spec file here. 
I have added request, urllib3 but didn't use openssl.




buildozer.spec

mahmud al hasan

unread,
Jul 2, 2018, 5:52:09 AM7/2/18
to kivy-...@googlegroups.com
The problem solved! I have included some requirements in the spec file which solved the issue.

requirements = kivy,requests,openssl,urllib3,futures,kivymd

Reply all
Reply to author
Forward
0 new messages