Search code examples
python-3.xkivyconfigparserbuildozer

Configparser under Kivy


I have a problem deploying a Kivy application using configparser

import kivy
from kivy.app import App
from kivy.uix.screenmanager import Screen

import configparser

class MainFrame(Screen):
    def __init__(self, **kwargs):
        super(MainFrame, self).__init__(**kwargs)
        pass

    def on_quit_button_click(self):
        quit()


class BasicApp(App):
    def build(self):
        return MainFrame()
        pass

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

with the following basic.kv

<MainFrame>:
    BoxLayout:
        Button:
            text: 'Click to quit ... test'
            on_press: root.on_quit_button_click()

It works perfectly on the pc and I can build and deploy on Android using buildozer provided I comment out the line

import configparser

With that line in the app closes as soon as the splash screen is displayed

my buildozer.spec file is here

and a copy of the logcat is here

[Update 2018.04.26:08:16]

I have done some debugging and when run on the android device it return an 'import error' at the point that it attempts to load configparser.

[Update 2018.04.26:08:41] It loads if I use ConfigParser (i.e. the Python 2 version). Is this a bug in configparser (Python 3)?


Solution

  • kivy comes with its own configparser. It appears this is based on the standard python configparser.

    Use:

    from kivy.config import ConfigParser