为了账号安全,请及时绑定邮箱和手机立即绑定

将 Python 版本和要求放入 buildozer spec 文件的正确方法是什么?

将 Python 版本和要求放入 buildozer spec 文件的正确方法是什么?

尚方宝剑之说 2023-03-08 17:18:13
当使用buildozer为 Android 或 iOS 构建 Kivy 应用程序时,这确实令人困惑。文档中没有提供将依赖项和要求放入 buildozer 规范文件的正确方法。现在我使用 Kivy 框架构建了一个应用程序,我想构建一个 .apk 文件以将其部署到 Android 上。我正在使用 buildozer 构建 apk 文件,因为它是文档中所示的推荐方式。该应用程序在我的笔记本电脑上运行完美,并且 buildozer 日志没有显示任何错误,事实上,它让我在工作结束时成功构建。不幸的是,在我的 Android 手机上部署 apk 文件并安装后,该应用程序崩溃了。UI根本不显示,点击图标后应用程序直接崩溃。由于没有日志错误,我假设这与我构建应用程序的方式或更准确地说是 buildozer 规范文件有关。这是我的 buildozer 规范文件:[app]# (str) Title of your applicationtitle = Overall Translator# (str) Package namepackage.name = overallTranslator# (str) Package domain (needed for android/ios packaging)package.domain = org.nidhal.overallTranslator# (str) Source code where the main.py livesource.dir = .# (list) Source files to include (let empty to include all the files)source.include_exts = py,png,jpg,kv,atlas,ttf# (list) List of inclusions using pattern matchingsource.include_patterns = assets/*,images/*.png, font/*.ttf# (list) Source files to exclude (let empty to not exclude anything)source.exclude_exts = spec, txt, md, gitignore# (list) List of directory to exclude (let empty to not exclude anything)source.exclude_dirs = tests, bin, venv# (list) List of exclusions using pattern matching#source.exclude_patterns = license,images/*/*.jpg# (str) Application versioning (method 1)#version = 0.1# (str) Application versioning (method 2)version.regex = __version__ = ['"](.*)['"]version.filename = %(source.dir)s/main.py# (list) Application requirements# comma separated e.g. requirements = sqlite3,kivyrequirements = hostpython3==3.7.8,python3==3.7.8,kivy==1.11.1, beautifulsoup4, bs4, certifi,chardet,docutils, future, idna, Kivy-Garden, Pygments, requests, six, soupsieve, urllib3, deep-translator, arabic-reshaper, python-bidi, openssl与任何项目一样,我的也有依赖项,我应该在规范文件中放入需求。这很令人困惑,因为没有描述如何以正确的方式做到这一点。例如,我有仅适用于 python >= 3.7 的库,我如何在要求中提供它?我在上面的规范文件中以正确的方式进行操作吗?
查看完整描述

1 回答

?
跃然一笑

TA贡献1826条经验 获得超6个赞

将 python 版本和要求放入 buildozer spec 文件的正确方法是什么?

对此的直接回答是使用 buildozer.spec 行的“您完成它的方式” requirements = hostpython3==3.7.8,python3==3.7.8。唯一需要注意的是,并不是所有的 python 小版本都一定能用,我不知道 3.7.8 好不好。如果可能,最好使用默认值,在这种情况下,这将使用 Python 3.8(但您需要清理构建并再次运行以实现此目的)。但是,您遇到的主要问题是不良的次要版本会导致编译失败,因此这可能不是您的问题。

您的问题显然是“为什么我的应用程序崩溃了?”。我建议单独询问该问题并包括完整的 logcat 输出。这可能比猜测原因并询问原因更有成效。


查看完整回答
反对 回复 2023-03-08
  • 1 回答
  • 0 关注
  • 181 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信