Kivy 应用程序使用 buildozer 成功构建,但在 android 手机上打开时崩溃 [英] Kivy app build successfully using buildozer but crashes when opened on android phone

查看:24
本文介绍了Kivy 应用程序使用 buildozer 成功构建,但在 android 手机上打开时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 kivy 构建一个应用程序,它可以在我的 Linux 笔记本电脑上完美运行.我使用 buildozer 为 android 构建应用程序,并且日志没有显示任何错误.完成后,会在 bin 文件夹中创建 apk 文件.

然后我复制 apk 文件并将其粘贴到我的手机存储中,然后安装该应用程序.

当我打开应用程序时,它会显示 kivy 徽标并正在加载……但随后它崩溃了!我尝试了一整天来寻找解决方案,但我无法实现.

我在谷歌搜索问题时发现了这个命令,它应该有助于调试,但我无法理解输出!:

buildozer android logcat

这是我运行此命令时打印的日志

 # 确保构建布局# 检查配置令牌# 运行 'dpkg --version'# Cwd 无Debian 'dpkg' 软件包管理程序版本 1.19.0.5 (amd64).这是免费软件;请参阅 GNU 通用公共许可证版本 2 或稍后用于复制条件.没有保修.# 搜索 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# 运行'/home/nidhal/.buildozer/android/platform/android-sdk/platform-tools/adb devices'# Cwd 无附加设备列表nidhal@nidhal-Latitude-E6320:~/Desktop/my_code/deep-translator-app$ clearnidhal@nidhal-Latitude-E6320:~/Desktop/my_code/deep-translator-app$ buildozer android logcat# 检查配置令牌# 确保构建布局# 检查配置令牌# 运行 'dpkg --version'# Cwd 无Debian 'dpkg' 软件包管理程序版本 1.19.0.5 (amd64).这是免费软件;请参阅 GNU 通用公共许可证版本 2 或稍后用于复制条件.没有保修.# 搜索 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# 运行'/home/nidhal/.buildozer/android/platform/android-sdk/platform-tools/adb devices'# Cwd 无附加设备列表

此外,我尝试在使用此命令运行构建时存储整个日志:

buildozer android debug deploy run logcat >日志.txt

这是日志文件

此外,以下是我对默认 buildozer.spec 文件所做的更改:

[应用程序]# (str) 应用程序的标题标题 = 整体翻译# (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) 要排除的源文件(留空不排除任何内容)source.exclude_exts = 规范、txt、md、gitignore# (list) 要排除的目录列表(留空表示不排除任何内容)source.exclude_dirs = 测试、bin、venv# (list) 使用模式匹配的排除列表#source.exclude_patterns = 许可证,图像/*/*.jpg# (str) 应用程序版本控制(方法 1)#版本 = 0.1# (str) 应用程序版本控制(方法 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) 需求的自定义源文件夹# 为带有配方的任何要求设置自定义源# requirements.source.kivy = ../../kivy#(列表)花园要求#garden_requirements =# (str) 应用程序的预启动#presplash.filename = %(source.dir)s/data/presplash.png# (str) 应用程序的图标#icon.filename = %(source.dir)s/data/icon.png# (str) 支持的方向(横向、传感器横向、纵向或全部之一)方向=纵向# (list) 要声明的服务列表#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY## OSX 特定###作者=©版权信息# 更改应用程序使用的 python 的主要版本osx.python_version = 3# 要使用的 Kivy 版本osx.kivy_version = 1.9.1#

编辑

这是 logcat 的输出p>

Edit2:在解决了@inclement 解决的 no module found 错误后,该应用程序仍然在我的 Android 手机上崩溃.这是我在运行应用程序时收到的新 logcat

解决方案

经过几天的调试,我终于找到了错误,这是我在项目中使用的一些第三方库引起的.很明显kivy、buildozer或者python-for-android都解析不了这个(不知道是怎么打包的).

如果有人遇到这个问题,我强烈建议使用模拟器进行调试,而不是依赖 logcat.就我而言,logcat 没用.它没有告诉我有关错误的任何信息.

我需要逐步尝试删除依赖项,直到发现错误.@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.

这篇关于Kivy 应用程序使用 buildozer 成功构建,但在 android 手机上打开时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆