問題描述
我正在使用 kivy 構(gòu)建一個(gè)應(yīng)用程序,它可以在我的 Linux 筆記本電腦上完美運(yùn)行.我使用 buildozer 為 android 構(gòu)建應(yīng)用程序,并且日志沒有顯示任何錯(cuò)誤.完成后,會在 bin 文件夾中創(chuàng)建 apk 文件.
然后我復(fù)制 apk 文件并將其粘貼到我的手機(jī)存儲中,然后安裝該應(yīng)用程序.
當(dāng)我打開應(yīng)用程序時(shí),它會顯示 kivy 徽標(biāo)并正在加載……但隨后它崩潰了!我嘗試了一整天來尋找解決方案,但我無法實(shí)現(xiàn).
我在谷歌搜索問題時(shí)發(fā)現(xiàn)了這個(gè)命令,它應(yīng)該有助于調(diào)試,但我無法理解輸出!:
buildozer android logcat
這是我運(yùn)行此命令時(shí)打印的日志
# 確保構(gòu)建布局# 檢查配置令牌# 運(yùn)行 'dpkg --version'# Cwd 無Debian 'dpkg' 軟件包管理程序版本 1.19.0.5 (amd64).這是免費(fèi)軟件;請參閱 GNU 通用公共許可證版本 2 或稍后用于復(fù)制條件.沒有保修.# 搜索 Git (git)#->在/usr/bin/git 找到# 搜索 Cython (cython)#->在/home/nidhal/.local/bin/cython 找到# 搜索Java編譯器(javac)#->位于/usr/lib/jvm/java-11-openjdk-amd64/bin/javac# 搜索Java keytool (keytool)#->位于/usr/lib/jvm/java-11-openjdk-amd64/bin/keytool# 運(yùn)行'/home/nidhal/.buildozer/android/platform/android-sdk/platform-tools/adb devices'# Cwd 無附加設(shè)備列表nidhal@nidhal-Latitude-E6320:~/Desktop/my_code/deep-translator-app$ clearnidhal@nidhal-Latitude-E6320:~/Desktop/my_code/deep-translator-app$ buildozer android logcat# 檢查配置令牌# 確保構(gòu)建布局# 檢查配置令牌# 運(yùn)行 'dpkg --version'# Cwd 無Debian 'dpkg' 軟件包管理程序版本 1.19.0.5 (amd64).這是免費(fèi)軟件;請參閱 GNU 通用公共許可證版本 2 或稍后用于復(fù)制條件.沒有保修.# 搜索 Git (git)#->在/usr/bin/git 找到# 搜索 Cython (cython)#->在/home/nidhal/.local/bin/cython 找到# 搜索Java編譯器(javac)#->位于/usr/lib/jvm/java-11-openjdk-amd64/bin/javac# 搜索Java keytool (keytool)#->位于/usr/lib/jvm/java-11-openjdk-amd64/bin/keytool# 運(yùn)行'/home/nidhal/.buildozer/android/platform/android-sdk/platform-tools/adb devices'# Cwd 無附加設(shè)備列表
此外,我嘗試在使用此命令運(yùn)行構(gòu)建時(shí)存儲整個(gè)日志:
buildozer android debug deploy run logcat >日志.txt
這是日志文件
此外,以下是我對默認(rèn) buildozer.spec 文件所做的更改:
[應(yīng)用程序]# (str) 應(yīng)用程序的標(biāo)題標(biāo)題 = 整體翻譯# (str) 包名package.name = 整體翻譯器# (str) 包域(android/ios打包需要)package.domain = org.nidhal.overallTranslator# (str) main.py 所在的源代碼源.dir = .# (list) 要包含的源文件(留空以包含所有文件)source.include_exts = py,png,jpg,kv,atlas,ttf# (list) 使用模式匹配的包含列表source.include_patterns = assets/*,images/*.png, font/*.ttf# (list) 要排除的源文件(留空不排除任何內(nèi)容)source.exclude_exts = 規(guī)范、txt、md、gitignore# (list) 要排除的目錄列表(留空表示不排除任何內(nèi)容)source.exclude_dirs = 測試、bin、venv# (list) 使用模式匹配的排除列表#source.exclude_patterns = 許可證,圖像/*/*.jpg# (str) 應(yīng)用程序版本控制(方法 1)#版本 = 0.1# (str) 應(yīng)用程序版本控制(方法 2)version.regex = __version__ = ['"](.*)['"]version.filename = %(source.dir)s/main.py# (list) 申請要求# 逗號分隔例如要求 = sqlite3,kivy要求 = hostpython3==3.7.8,python3==3.7.8,kivy==1.11.1,beautifulsoup4,bs4,certifi,chardet,docutils,future,idna,Kivy-Garden,Pygments,requests,六,soupsieve,urllib3, 深度翻譯器, 阿拉伯語整形器, python-bidi, openssl# (str) 需求的自定義源文件夾# 為帶有配方的任何要求設(shè)置自定義源# requirements.source.kivy = ../../kivy#(列表)花園要求#garden_requirements =# (str) 應(yīng)用程序的預(yù)啟動(dòng)#presplash.filename = %(source.dir)s/data/presplash.png# (str) 應(yīng)用程序的圖標(biāo)#icon.filename = %(source.dir)s/data/icon.png# (str) 支持的方向(橫向、傳感器橫向、縱向或全部之一)方向=縱向# (list) 要聲明的服務(wù)列表#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY## OSX 特定###作者=?版權(quán)信息# 更改應(yīng)用程序使用的 python 的主要版本osx.python_version = 3# 要使用的 Kivy 版本osx.kivy_version = 1.9.1#
編輯
這是 logcat 的輸出p>
Edit2:在解決了@inclement 解決的 no module found 錯(cuò)誤后,該應(yīng)用程序仍然在我的 Android 手機(jī)上崩潰.這是我在運(yùn)行應(yīng)用程序時(shí)收到的新 logcat
經(jīng)過幾天的調(diào)試,我終于找到了錯(cuò)誤,這是我在項(xiàng)目中使用的一些第三方庫引起的.很明顯kivy、buildozer或者python-for-android都解析不了這個(gè)(不知道是怎么打包的).
如果有人遇到這個(gè)問題,我強(qiáng)烈建議使用模擬器進(jìn)行調(diào)試,而不是依賴 logcat.就我而言,logcat 沒用.它沒有告訴我有關(guān)錯(cuò)誤的任何信息.
我需要逐步嘗試刪除依賴項(xiàng),直到發(fā)現(xiàn)錯(cuò)誤.@inclement 的回答和評論也很有幫助.
I'm building an app using kivy and it works perfectly on my Linux laptop. I build the app for android using buildozer and the log does not show any errors. When it was complete, the apk file is created in the bin folder.
I then copy the apk file and paste it on my phone storage and then install the app.
When I open the app, it shows the kivy logo and loading... but then it crashes! I tried the whole day to find a solution but I could not achieve that.
I find this command while googling the problem and it should be helpful for debugging but I can't understand the output!:
buildozer android logcat
This is the log that gets printed when I run this command
# Ensure build layout
# Check configuration tokens
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.0.5 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
# -> found at /usr/bin/git
# Search for Cython (cython)
# -> found at /home/nidhal/.local/bin/cython
# Search for Java compiler (javac)
# -> found at /usr/lib/jvm/java-11-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
# -> found at /usr/lib/jvm/java-11-openjdk-amd64/bin/keytool
# Run '/home/nidhal/.buildozer/android/platform/android-sdk/platform-tools/adb devices'
# Cwd None
List of devices attached
nidhal@nidhal-Latitude-E6320:~/Desktop/my_code/deep-translator-app$ clear
nidhal@nidhal-Latitude-E6320:~/Desktop/my_code/deep-translator-app$ buildozer android logcat
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.0.5 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
# -> found at /usr/bin/git
# Search for Cython (cython)
# -> found at /home/nidhal/.local/bin/cython
# Search for Java compiler (javac)
# -> found at /usr/lib/jvm/java-11-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
# -> found at /usr/lib/jvm/java-11-openjdk-amd64/bin/keytool
# Run '/home/nidhal/.buildozer/android/platform/android-sdk/platform-tools/adb devices'
# Cwd None
List of devices attached
Furthermore, I tried to store the whole log when running the build using this command:
buildozer android debug deploy run logcat > log.txt
here is the log file
Moreover, here are the changes that I made to the default buildozer.spec file:
[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
#
EDIT
here is the output of the logcat
Edit2: After resolving the no module found error adressed by @inclement, the app still crashes on my android phone. Here is the new logcat i receive when i run the app
After days of debugging, I finally find the error, which is caused by some third party libraries that I used in my project. Obviously, kivy, buildozer or python-for-android could not parse this (I don't know how the packaging is done).
If anyone is having this problem, I highly recommend debugging with an emulator and not relying on the logcat. In my case the logcat was useless. It did not tell me nothing about the error.
I needed to try step by step removing dependencies until I found the error. Answer and comment of @inclement were also helpful.
這篇關(guān)于Kivy 應(yīng)用程序使用 buildozer 成功構(gòu)建,但在 android 手機(jī)上打開時(shí)崩潰的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!