【问题标题】:What is the correct way to put Python version and requirements in buildozer spec file?将 Python 版本和要求放入 buildozer 规范文件的正确方法是什么?
【发布时间】:2020-11-05 05:39:31
【问题描述】:

当使用buildozer 为 Android 或 iOS 构建 Kivy 应用程序时,这确实令人困惑。文档中没有提供将依赖项和要求放入 buildozer 规范文件的正确方法。

现在我使用 Kivy 框架构建了一个应用程序,我想构建一个 .apk 文件以将其部署到 Android 上。我正在使用 buildozer 构建 apk 文件,因为它是文档中显示的推荐方式。

该应用程序在我的笔记本电脑上完美运行,并且 buildozer 日志显示没有错误,事实上它在工作结束时让我成功构建。不幸的是,在我的安卓手机上部署apk文件并安装后,应用程序崩溃了。界面完全不显示,点击图标后应用直接崩溃。

由于没有日志错误,我假设这与我如何构建应用程序或更准确地说是 buildozer 规范文件有关。这是我的 buildozer 规范文件:

[app]

# (str) Title of your application
title = Overall Translator

# (str) Package name
package.name = overallTranslator

# (str) Package domain (needed for android/ios packaging)
package.domain = org.nidhal.overallTranslator

# (str) Source code where the main.py live
source.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 matching
source.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,kivy
requirements = 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

# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy

# (list) Garden requirements
#garden_requirements =

# (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png

# (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png

# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
orientation = portrait

# (list) List of service to declare
#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY

#
# OSX Specific
#

#
# author = © Copyright Info

# change the major version of python used by the app
osx.python_version = 3

# Kivy version to use
osx.kivy_version = 1.9.1

#

与任何项目一样,我的项目也有依赖项,我应该将需求放入规范文件中。这令人困惑,因为没有描述如何以正确的方式做到这一点。例如,我有仅适用于 python >= 3.7 的库,我如何在需求中提供它?我在上面的规范文件中做对了吗?

此外,我是否以正确的方式提供每个包的版本?我发布了this question,当我在手机上打开应用程序时,我提供了构建和调试模式的日志输出,但我没有收到任何有用的信息。该问题包含日志。

【问题讨论】:

  • 别猜了,debug。发布运行应用程序的 logcat 输出。
  • 也不要尝试指定python版本,让buildozer使用默认版本(3.8)。
  • @inclement 我在上一个问题中更新并发布了 logcat。我尝试不指定 python 版本,但这没有帮助
  • 您提出了一个新问题,寻求帮助以调试故障,因此您需要包含包含用于该调试的详细信息的 logcat 输出。您是否也在另一个问题上发布了它并不重要。

标签: python android kivy kivy-language buildozer


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-21
    • 1970-01-01
    • 2017-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多