简体   繁体   English

buildozer kivy应用程序无法在带有外部kv文件的android上运行

[英]buildozer kivy app wont run on android with external kv file

I'm newbie in coding with python/kivy. 我是python / kivy编码的新手。 I have a problem building an android app via kivy buildozer. 我在通过kivy buildozer构建android应用时遇到问题。

First of all, if I build the app and I use kivy like this for example: 首先,如果我构建了该应用程序,并且使用了如下所示的kivy:

self.asdbut = Button(text="xxxxxx", font_size="70sp")
self.asdbut.bind(on_press=self.aaaaa)
self.add_widget(self.asdbut)

It works on both on pc and android phone. 它可以在PC和Android手机上使用。

But if I use kivy builder for external or inner script kv language the app runs on pc but not in android. 但是,如果我使用kivy builder作为外部或内部脚本kv语言,则该应用程序可在PC上运行,但不能在android中运行。 So I guess I have to somehow add the kivy.lang.builder to the apk via buildozer init file. 所以我想我必须通过buildozer初始化文件将kivy.lang.builder添加到apk中。 How can I achive that? 我该如何实现?

PS I've found a line in buildozer spec that say's : 附注:我在buildozer规范中发现了一条线,说:

# (list) Application requirements
requirements = kivy

So i've tried to include there builder but it didn't work. 所以我试图包括那里建设者,但没有奏效。

Builder is class, not package. Builder是类,而不是包。 For loading either name it like your App class ( class My(App): -> my.kv ), or load with Builder this way: 要加载该文件,请像您的App类( class My(App): -> my.kv )一样my.kv ,或通过以下方式与Builder一起加载:

Builder.load_string('''
<My>:
    property: value
''')

or 要么

Builder.load_file(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'my.kv'))

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

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