How to test the application with Kivymd?

Asked

Viewed 133 times

3

I’ve developed a small test app that checks both the battery status and whether the phone is being charged.

The app is running local from python main.py, but when I install it in Android Studio Emulator, the software initializes and closes.

Updating

The package for Android is being generated with the buildozer

buildozer.spec (only settings)

[app]
title = My Test
package.name = mytest
package.domain = org.test
source.dir = .
source.include_exts = py,png,jpg,kv,atlas
source.exclude_exts = spec
version = 0.1
requirements = python3, kivy==2.0.0, kivymd==0.104.1, sdl2_ttf == 2.0.15
icon.filename = %(source.dir)s/data/icon.png
orientation = portrait
osx.python_version = 3
osx.kivy_version = 1.9.1
fullscreen = 0
android.permissions = BATTERY_STATS
android.arch = armeabi-v7a

[buildozer]
log_level = 2
warn_on_root = 1

End of update

I already understand that the problem is when I use the kivimd, with the kivy worked.

Follows the code

mytest.Kv

#:import MDLabel kivymd.uix.label
#:import MDBoxLayout kivymd.uix.boxlayout
#:import MDFloatLayout kivymd.uix.floatlayout
#:import MDTextButton kivymd.uix.button

<Page>:
    lbl1: lbl1
    lbl2: lbl2
    MDFloatLayout:
        MDTextButton:
            center: root.center
            size_hint_y: None
            pos_hint: {'y': .5}
            text: "Battery Status"
            on_press: root.get_status()
        MDBoxLayout:
            size_hint_y: None
            pos_hint: {'y': .1}
            MDLabel:
                text: "Is Charging?"
            MDLabel:
                id: lbl1
                text:
            MDLabel:
                text: "Percentage"
            MDLabel:
                id: lbl2
                text:

main py.

from kivymd.app import MDApp
from kivymd.uix.boxlayout import MDBoxLayout

from plyer import battery


class Page(MDBoxLayout):

    def get_status(self, *args):
        self.lbl1.text = str(battery.status['isCharging'])
        self.lbl2.text = str(battery.status['percentage']) + "%"


class MyTest(MDApp):

    def build(self):
        return Page()

    def on_pause(self):
        return True


if __name__ == "__main__":
    app = MyTest()
    app.run()

Note: Replacing kivymd for kivy and replacing from MD to , works.

If you need more information, please comment on the post.

  • 2

    For those who voted against this question, could you tell me why I can improve it?

  • I’m sorry, I don’t understand. Have you solved your problem? If so, answer your own question to stay in Q&A format instead of adding notes to the question. It’s hard to understand the way it is.

  • @Lucas. The problem NAY is solved. Are you familiar with the mobile development process using the Kivy framework? Kivymd is from the same group of Kivy developers. What I asked is using the Kivy framework is working, but with Kivymd it is not. Why Kivymd? Good question. It brings facilities to the layout.

1 answer

0

I had the same problem: a simple application that didn’t work on android with kivymd, but that worked with kivy. I was able to solve the problem by changing in buildozer.spec the Resets (according to the kitchen_sink demo on github):

Check = python3,kivy==2.0.0,https://github.com/kivymd/KivyMD/archive/master.zip,certifi,Pillow

Where is commented: "(str) Custom source folders for Documents. Sets custom source for any Requirements with Recipes" remove the comment and change from kivy to kivymd:

Menus.source.kivymd = .. /.. /kivymd

Browser other questions tagged

You are not signed in. Login or sign up in order to post.