简体   繁体   English

我是 Kivy 和使用 buildozer 的新手。我制作了一个 apk,但是当我打开它时它崩溃了

[英]I am new to Kivy and using buildozer.I making an apk but it's crash when i open it

from kivy.lang import Builder

from kivymd.app import MDApp
from kivymd.uix.label import MDLabel
from kivy.core.text import LabelBase
from kivymd.font_definitions import theme_font_styles

import datetime

x = datetime.datetime.now()
now = datetime.date(x.year,x.month,x.day)
uwu = datetime.date(2019,10,19)
delta = now - uwu

KV = '''
MDScreen:
    FitImage:
        source:"Luv.jpg"
    MDBoxLayout:
        id: box
        orientation: "vertical"
'''


class Test(MDApp):
    def build(self):
        
        LabelBase.register(name='Loving', 
                   fn_regular='loving.ttf')
        theme_font_styles.append('Loving')
        self.theme_cls.font_styles["Loving"] = ["Loving",65,False,0.15,]
        screen = Builder.load_string(KV)
        screen.ids.box.add_widget(
                                MDLabel(
                                    text=f'{delta.days} days moahhh!',
                                    halign="center",
                                    valign="bottom",
                                    theme_text_color="Error",
                                    font_style="Loving",
                                )
                            )
        return screen


Test().run()

I used datetime kivy and kivymd to create this program I use the image to set the background and change the font I don't know exactly which libraries should be included in buidozer's requriment.我使用 datetime kivy 和 kivymd 来创建这个程序 我使用图像来设置背景并更改字体 我不知道具体哪些库应该包含在 buidozer 的要求中。 What are the things I need to include in the buildozer requirement?我需要在构建器要求中包含哪些内容?

If you are using pictures in your app, you must include pillow in requirements .如果您在应用中使用图片,则必须在requirements中包含pillow

I see two possible problems in your code.我在您的代码中看到两个可能的问题。

First, you're using the kivy and the kivymd package.首先,您使用的是kivykivymd package。 Did you specify these in the buildozer.spec file as requirements?您是否在buildozer.spec文件中将这些指定为要求?
Further, you're using a loving.ttf font file.此外,您正在使用loving.ttf字体文件。 Normally, .ttf files are not automatically included in the build process of buildozer, you need to state that in source.include_exts =... , also in your buildozer.spec file.通常, .ttf文件不会自动包含在 buildozer 的构建过程中,您需要 state 在 source.include_exts source.include_exts =...中,也在您的buildozer.spec文件中。

Also, it might be helpful to connect your phone and enable USB-debugging.此外,连接手机并启用 USB 调试可能会有所帮助。 Then, you can use adb (Android Debug Bridge), eg to display all log messages of your phone (including the error message of your app) by typing adb logcat .然后,您可以使用 adb(Android 调试桥),例如通过输入adb logcat来显示您手机的所有日志消息(包括您的应用程序的错误消息)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM