Search code examples
pythonandroidkivykivymdbuildozer

KivyMD: ToolBar doesn't work on Android. App crashes


I'm stuck with a strange problem. My app works perfect with kivymd toolbar MDTopAppBar on Windows (after compiling with pyinstaller too) and Ubuntu. But, when I try to add this element even in the simpliest app and create .apk using buildozer, my app crashes immediatly after launch.

Here are examples of main.py and main.kv

main.py

from kivy.config import Config
Config.set('graphics', 'resizable', 0)
Config.set("graphics", "width", 360)
Config.set("graphics", "height", 740)

from kivymd.app import MDApp
from kivy.lang import Builder

class MesApp(MDApp):

    def build(self):
        return Builder.load_file('main.kv')

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

main.kv

<Screen>:
MDBoxLayout:
    orientation: 'vertical'
    padding: dp(5), dp(5)

    MDTopAppBar:
        title: 'Some toolbar'

    MDLabel:
        text: 'Some text'
        pos_hint: {"center_x": 0.9}  

Requirements from buildozer.spec:

requirements = kivy==2.1.0, kivymd==1.1.1, sdl2_ttf == 2.0.15, pillow

If we remove two lines with MDTopAppBar from main.kv this app works fine. Here's some log with crashing:

...
11-09 20:01:25.672 15328 15466 I python  : [INFO   ] [Base        ] Start application main loop
11-09 20:01:25.674 15328 15466 I python  : [INFO   ] [GL          ] NPOT texture support is available
--------- beginning of crash
11-09 20:01:25.715 15328 15466 F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x40 in tid 15466 (SDLThread), pid 15328 (stone.mytestapp)
# org.testone.mytestapp terminated

Googling this error didn't help. Is there something wrong with my code? Or it's something about buildozer and this specific element MDTopAppBar? I just don't understand in detail how build process works and what's going on there.
OS: Ubuntu 22.04.1 LTS
Python: 3.10.6
Device: Google Pixel 4a, Android 11
buildozer: 1.4.0. Installed it according to the official documentation.


Solution

  • For anyone out there facing this, there has been an issue on the kivymd github repo about this and this problem is caused by changes in the latest opengl version and changes in sdl versions. The best thing to do for now is to use kivymd==1.0.2 in the requirements while compiling apk and it should work fine.