buildozer 构建 apk 但不适用于 android
Posted
技术标签:
【中文标题】buildozer 构建 apk 但不适用于 android【英文标题】:buildozer build the apk but don't work on android 【发布时间】:2021-06-22 18:18:16 【问题描述】:您好,我已经使用以下命令构建了 apk:
buildozer android debug deploy 运行 logcat:
03-25 22:34:57.822 29612 30258 I python : [INFO ] [Window ] auto add sdl2 input provider
03-25 22:34:57.824 29612 30258 I python : [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
03-25 22:34:57.828 29612 30258 I python : [INFO ] [KivyMD ] 0.104.2.dev0, git-Unknown, 2021-01-17 (installed at "./kivymd/__init__.pyc")
03-25 22:34:57.846 29612 30258 I python : [INFO ] [Text ] Provider: sdl2
03-25 22:34:58.090 2824 30154 I display : [PrimaryDisplay] [DYNAMIC_RECOMP] HWC_2_GLES by low FPS(0)
03-25 22:34:58.532 29612 30258 I python : [INFO ] [GL ] NPOT texture support is available
03-25 22:34:59.162 29612 30258 I python : Traceback (most recent call last):
03-25 22:34:59.163 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/lang/builder.py", line 702, in _apply_rule
03-25 22:34:59.164 29612 30258 I python : File "kivy/weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
03-25 22:34:59.165 29612 30258 I python : File "kivy/properties.pyx", line 520, in kivy.properties.Property.__set__
03-25 22:34:59.165 29612 30258 I python : File "kivy/properties.pyx", line 555, in kivy.properties.Property.set
03-25 22:34:59.166 29612 30258 I python : File "kivy/properties.pyx", line 1264, in kivy.properties.BoundedNumericProperty.check
03-25 22:34:59.167 29612 30258 I python : TypeError: Cannot convert kivy.properties.NumericPropertyStorage to kivy.properties.BoundedNumericPropertyStorage
03-25 22:34:59.167 29612 30258 I python :
03-25 22:34:59.168 29612 30258 I python : During handling of the above exception, another exception occurred:
03-25 22:34:59.168 29612 30258 I python :
03-25 22:34:59.169 29612 30258 I python : Traceback (most recent call last):
03-25 22:34:59.169 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/app/main.py", line 182, in <module>
03-25 22:34:59.170 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/app.py", line 954, in run
03-25 22:34:59.171 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/app.py", line 924, in _run_prepare
03-25 22:34:59.171 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/app/main.py", line 85, in build
03-25 22:34:59.172 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/lang/builder.py", line 307, in load_file
03-25 22:34:59.173 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/lang/builder.py", line 409, in load_string
03-25 22:34:59.174 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/lang/builder.py", line 662, in _apply_rule
03-25 22:34:59.175 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/uix/widget.py", line 463, in apply_class_lang_rules
03-25 22:34:59.175 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/lang/builder.py", line 542, in apply
03-25 22:34:59.176 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/lang/builder.py", line 664, in _apply_rule
03-25 22:34:59.177 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/lang/builder.py", line 662, in _apply_rule
03-25 22:34:59.178 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/uix/widget.py", line 463, in apply_class_lang_rules
03-25 22:34:59.179 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/lang/builder.py", line 542, in apply
03-25 22:34:59.179 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/lang/builder.py", line 711, in _apply_rule
03-25 22:34:59.180 29612 30258 I python : kivy.lang.builder.BuilderException: Parser: File "<inline>", line 15:
03-25 22:34:59.181 29612 30258 I python : ...
03-25 22:34:59.181 29612 30258 I python : 13: size_hint: None, None
03-25 22:34:59.181 29612 30258 I python : 14: height: dp(20) + root.lbl_txt.texture_size[1]
03-25 22:34:59.182 29612 30258 I python : >> 15: width: lbl_txt.texture_size[0] + dp(24)
03-25 22:34:59.182 29612 30258 I python : 16:
03-25 22:34:59.182 29612 30258 I python : 17: MDLabel:
03-25 22:34:59.183 29612 30258 I python : ...
03-25 22:34:59.183 29612 30258 I python : TypeError: Cannot convert kivy.properties.NumericPropertyStorage to kivy.properties.BoundedNumericPropertyStorage
03-25 22:34:59.183 29612 30258 I python : File "/home/lauri/Py/beach_order/client/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/order/kivy/lang/builder.py", line 702, in _apply_rule
03-25 22:34:59.184 29612 30258 I python : File "kivy/weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
03-25 22:34:59.184 29612 30258 I python : File "kivy/properties.pyx", line 520, in kivy.properties.Property.__set__
03-25 22:34:59.184 29612 30258 I python : File "kivy/properties.pyx", line 555, in kivy.properties.Property.set
03-25 22:34:59.184 29612 30258 I python : File "kivy/properties.pyx", line 1264, in kivy.properties.BoundedNumericProperty.check
03-25 22:34:59.185 29612 30258 I python :
03-25 22:34:59.185 29612 30258 I python : Python for android ended.
请帮帮我!!我不明白这个问题。 我已经构建了 apk 并运行,但在启动时崩溃。 昨天,在我更改了规范文件并收到此错误后,该应用程序正在运行。我按照原样重写了规范文件,但错误始终存在
唯一不同的是我更新的是 ubuntu 20.04 lts、应用程序和内核。
我尝试删除 .buildozer 文件夹和 .spec 文件
之后:
buildozer 初始化和 添加需求
# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = android,python3==3.8.5,kivy==master,https://github.com/kivymd/KivyMD/archive/master.zip,pygments,sdl2_ttf==2.0.15,jnius,pyjnius,plyer,pillow,xclip,xsel
【问题讨论】:
【参考方案1】:width: root.lbl_txt.texture_size[0] + dp(24)
?
【讨论】:
字符串在 kivy.lang.builder 中,不在我的脚本中 尝试部署一个 HelloWorld 应用程序以确保它来自 buildozer。如果 Hello World 崩溃 -> 更改 buildozer 版本,直到它正常工作。如果 Hello World 工作正常,您应该检查您的代码/库/path_needed 并一点一点实施。【参考方案2】:这是 KivyMD 和/或您自己的代码中的一个错误,由 Kivy master 最近的更改所揭示。使用最新的 Kivy 版本,或等待它在 Kivy MD 中修复。
详情请见https://github.com/kivy/kivy/issues/7398。
【讨论】:
谢谢!!这么多以上是关于buildozer 构建 apk 但不适用于 android的主要内容,如果未能解决你的问题,请参考以下文章
Kivy App 使用 Buildozer 构建。 APK 崩溃
Buildozer 编译 apk,但它在 android 上崩溃
由 buildozer 构建的 Kivy apk 在显示预启动屏幕后很快崩溃