當(dāng)使用buildozer為 Android 或 iOS 構(gòu)建 Kivy 應(yīng)用程序時,這確實(shí)令人困惑。文檔中沒有提供將依賴項(xiàng)和要求放入 buildozer 規(guī)范文件的正確方法?,F(xiàn)在我使用 Kivy 框架構(gòu)建了一個應(yīng)用程序,我想構(gòu)建一個 .apk 文件以將其部署到 Android 上。我正在使用 buildozer 構(gòu)建 apk 文件,因?yàn)樗俏臋n中所示的推薦方式。該應(yīng)用程序在我的筆記本電腦上運(yùn)行完美,并且 buildozer 日志沒有顯示任何錯誤,事實(shí)上,它讓我在工作結(jié)束時成功構(gòu)建。不幸的是,在我的 Android 手機(jī)上部署 apk 文件并安裝后,該應(yīng)用程序崩潰了。UI根本不顯示,點(diǎn)擊圖標(biāo)后應(yīng)用程序直接崩潰。由于沒有日志錯誤,我假設(shè)這與我構(gòu)建應(yīng)用程序的方式或更準(zhǔn)確地說是 buildozer 規(guī)范文件有關(guān)。這是我的 buildozer 規(guī)范文件:[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與任何項(xiàng)目一樣,我的也有依賴項(xiàng),我應(yīng)該在規(guī)范文件中放入需求。這很令人困惑,因?yàn)闆]有描述如何以正確的方式做到這一點(diǎn)。例如,我有僅適用于 python >= 3.7 的庫,我如何在要求中提供它?我在上面的規(guī)范文件中以正確的方式進(jìn)行操作嗎?
1 回答

躍然一笑
TA貢獻(xiàn)1826條經(jīng)驗(yàn) 獲得超6個贊
將 python 版本和要求放入 buildozer spec 文件的正確方法是什么?
對此的直接回答是使用 buildozer.spec 行的“您完成它的方式” requirements = hostpython3==3.7.8,python3==3.7.8
。唯一需要注意的是,并不是所有的 python 小版本都一定能用,我不知道 3.7.8 好不好。如果可能,最好使用默認(rèn)值,在這種情況下,這將使用 Python 3.8(但您需要清理構(gòu)建并再次運(yùn)行以實(shí)現(xiàn)此目的)。但是,您遇到的主要問題是不良的次要版本會導(dǎo)致編譯失敗,因此這可能不是您的問題。
您的問題顯然是“為什么我的應(yīng)用程序崩潰了?”。我建議單獨(dú)詢問該問題并包括完整的 logcat 輸出。這可能比猜測原因并詢問原因更有成效。
添加回答
舉報(bào)
0/150
提交
取消