[英]How to debug a Kivy/Kivymd app for android?
So I have spent some time developing a recipe app: Github I can use with my Raspberry Pi, which works great and I don't mind using a launcher for the raw code there.所以我花了一些时间开发了一个食谱应用程序: Github我可以在我的 Raspberry Pi 上使用它,它工作得很好,我不介意在那里使用启动器来获取原始代码。 However I wanted to be able to package the Kivy application as an apk using the buildozer method:
但是我希望能够使用 buildozer 方法将 Kivy 应用程序打包为 apk:
buildozer android debug deploy run
Which compiles successfully and the apk installs fine, however the application crashes after a second, after that I tried using the Kivy Launcher which never seems to recognise my program, so i moved on to trying to run the raw code through Pydroid 3, which has worked in the past for both Kivy and KivyMD however it crashes trying this import which isnt a part of my code:编译成功并且 apk 安装正常,但是应用程序在一秒钟后崩溃,之后我尝试使用似乎从未识别过我的程序的 Kivy Launcher,所以我继续尝试通过 Pydroid 3 运行原始代码,它具有过去曾为 Kivy 和 KivyMD 工作过,但是尝试这个不是我代码一部分的导入时它崩溃了:
from android.config import JAVA_NAMESPACE, JNI_NAMESPACE
my buildozer.spec file is:我的 buildozer.spec 文件是:
https://github.com/treencd/RecipeBook/blob/master/buildozer.spec https://github.com/treencd/RecipeBook/blob/master/buildozer.spec
I eventually tried using:我最终尝试使用:
adb logcat
However the output doesn't seem that helpful or I dont know what i'm looking for.但是输出似乎没有帮助,或者我不知道我在寻找什么。
I could really use some direction on how to go about debugging an application like this.我真的可以使用一些关于如何调试这样的应用程序的指导。
Using adb logcat is the way to go.使用 adb logcat 是要走的路。 Amongst (many) other things, this includes all the normal logging output of your application, just as you would see on the desktop.
在(许多)其他事情中,这包括您的应用程序的所有正常日志输出,就像您在桌面上看到的一样。 You can also do more advanced debugging, but this is usually sufficient for debugging basic issues (just as on the desktop, seeing the traceback is most of the information you often need).
您还可以进行更高级的调试,但这通常足以调试基本问题(就像在桌面上一样,查看回溯是您经常需要的大部分信息)。
The python-related lines in the output all have the tag "python".输出中与 python 相关的行都带有标签“python”。 There's an adb syntax for showing only output matching a specific tag, but I can never remember it and just use grep -
adb logcat | grep python
有一个 adb 语法只显示与特定标签匹配的输出,但我永远记不住它,只使用 grep -
adb logcat | grep python
adb logcat | grep python
is fine. adb logcat | grep python
很好。
If this doesn't return anything runtime python output, it means that the application is crashing before getting to that point, and you'll have to more carefully inspect the logcat.如果这没有返回任何运行时 python 输出,则意味着应用程序在到达该点之前崩溃了,您必须更仔细地检查 logcat。 If this is the case, post the logcat here.
如果是这种情况,请在此处发布 logcat。
You need 3 steps (omitted enabling debug mode on cellphone).您需要 3 个步骤(省略在手机上启用调试模式)。 You can save each step as bash files then run the scripts easily.
您可以将每个步骤保存为 bash 文件,然后轻松运行脚本。 Assuming the folder structure below
假设文件夹结构如下
project/
1.bash
2.bash
3.bash
bin/
random_name.apk
main.py
main.kv
1) Build apk (1.bash) 1) 构建 apk (1.bash)
#!/bin/sh
buildozer -v android debug
2) Install on cellphone from terminal (2.bash) 2)从终端(2.bash)安装在手机上
#!/bin/sh
adb install -r bin/*.apk
3) Running the apk and see what's happening (3.bash) 3) 运行 apk 看看发生了什么 (3.bash)
#!/bin/sh
echo 'Please connect on transfer files mode the cellphone'
adb logcat -s "python"
Then when all is working just create a new file (0.bash)然后当一切正常时,只需创建一个新文件(0.bash)
#!/bin/sh
bash 1.bash
bash 2.bash
bash 3.bash
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.