【发布时间】:2020-11-02 01:06:58
【问题描述】:
我正在使用 kivy 构建一个应用程序,它可以在我的 Linux 笔记本电脑上完美运行。我使用buildozer 为android 构建了应用程序,并且日志没有显示任何错误。完成后,会在 bin 文件夹中创建 apk 文件。
然后我复制 apk 文件并将其粘贴到我的手机存储中,然后安装该应用程序。
当我打开应用程序时,它会显示 kivy 徽标并正在加载……但随后它崩溃了!我尝试了一整天来寻找解决方案,但我无法实现。
我在谷歌搜索问题时发现了这个命令,它应该有助于调试,但我无法理解输出!:
buildozer android logcat
这是我运行此命令时打印的日志
# 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
此外,我尝试在使用此命令运行构建时存储整个日志:
buildozer android debug deploy run logcat > log.txt
这是log 文件
此外,以下是我对默认 buildozer.spec 文件所做的更改:
[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
#
编辑
这是logcat的输出
Edit2:在解决了@inclement 解决的 no module found 错误后,该应用程序仍然在我的 Android 手机上崩溃。这是我在运行应用程序时收到的新logcat
【问题讨论】:
-
贴一下logcat的输出,你贴的好像没有。
-
@inclement 我提供了整个输出的链接。单击链接(日志字)它将带您到保管箱文件
-
不包含logcat日志。
-
@inclement 在官方文档buildozer.readthedocs.io/en/latest/quickstart.html中明确写到使用该命令时可以将logcat保存到log.txt文件中。所以这意味着 log.txt 内容是我在链接中提供的 logcat 输出
-
logcat 输出是来自设备的日志流。看起来你从来没有收到过任何东西。由于您收到的最后一件事是连接的设备的空列表,您是否真的插入了设备并启用了 USB 调试?
标签: python android kivy kivy-language buildozer