android 上的 Kivy 应用仅加载(3 秒)然后自行关闭
Kivy app on android only loads (3 seconds) and then closes itself
已解决问题:
I would like to ask about a Kivy-Python app just built using
buildozer
on the Oracle virtual machine. The app is written in
Windows, python 3 using kivy
and depends on numpy
, and some
.png
file.
Building the apk file :
On the virtual machine Linux terminal, I have set the project folder
that contains the main file main.py
, and then run:
buildozer android debug
the process by this line took quite some time. The apk file has size
of 11MB. After I plug in the phone, I ran (on VM Linux terminal):
buildozer android deploy run
The app was installed on the phone.
The problem :
But when I open it : it only says "loading..." alongside with the
Kivy logo and then it closes itself. What causes this?
The python that I saw in the VM terminal is python 2.7.13
while my
code was written in python 3
. Is this the problem? If it is, what
is the solution?
Hope to get feedbacks on this. Thanks.
解决方案:
The solution was to rewrite the code such that it works in python 2.7
. Now the code works in Python2 and Python3. Then I build the apk using this edited main.py
. Now, it does not crash.
您可以通过取消注释 buildozer.specs 中的 "android.logcat_filters = *:S python:D" 行来添加正则表达式来过滤某些 logcat 的输出(只需查看有关 python 的日志,但您可以添加一些信息以过滤更多信息。)。
我也遇到了与此配置类似的问题(python3 在计算机上,python2 在 android 上,是的,你必须使你的代码 "almost" 两者兼容)。
为此,需要记住一些简单的步骤(我可能会忘记一些):
在定义静态方法之前添加“@static-method”行
在 python 个子文件夹
上添加一个空的“__init__.py”文件
我怀疑是 numpy 配方的问题,但它可以,所以你可以在 buildozer.specs 中添加你想使用的版本,或者只是清理 buildozer 再次测试。
希望这对你有帮助,让我知道:)
已解决问题:
I would like to ask about a Kivy-Python app just built using
buildozer
on the Oracle virtual machine. The app is written in Windows, python 3 usingkivy
and depends onnumpy
, and some.png
file.Building the apk file :
On the virtual machine Linux terminal, I have set the project folder that contains the main file
main.py
, and then run:buildozer android debug
the process by this line took quite some time. The apk file has size of 11MB. After I plug in the phone, I ran (on VM Linux terminal):
buildozer android deploy run
The app was installed on the phone.
The problem :
But when I open it : it only says "loading..." alongside with the Kivy logo and then it closes itself. What causes this?
The python that I saw in the VM terminal is
python 2.7.13
while my code was written inpython 3
. Is this the problem? If it is, what is the solution?Hope to get feedbacks on this. Thanks.
解决方案:
The solution was to rewrite the code such that it works in
python 2.7
. Now the code works in Python2 and Python3. Then I build the apk using this editedmain.py
. Now, it does not crash.
您可以通过取消注释 buildozer.specs 中的 "android.logcat_filters = *:S python:D" 行来添加正则表达式来过滤某些 logcat 的输出(只需查看有关 python 的日志,但您可以添加一些信息以过滤更多信息。)。
我也遇到了与此配置类似的问题(python3 在计算机上,python2 在 android 上,是的,你必须使你的代码 "almost" 两者兼容)。
为此,需要记住一些简单的步骤(我可能会忘记一些):
在定义静态方法之前添加“@static-method”行
在 python 个子文件夹
我怀疑是 numpy 配方的问题,但它可以,所以你可以在 buildozer.specs 中添加你想使用的版本,或者只是清理 buildozer 再次测试。
希望这对你有帮助,让我知道:)