Kivy app on android only loads (3 seconds) and then closes itself

不打扰是莪最后的温柔 提交于 2020-01-15 12:13:21

问题


SOLVED PROBLEM :

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.

SOLUTION :

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.


回答1:


You can add a regex to filter some logcat's outputs by uncommenting the "android.logcat_filters = *:S python:D" line in the buildozer.specs, (it's just look at log concerning python, but you can add some info to filter more.).

Also I went through similars problems with this configuration (python3 on computer, and python2 on android, and yes, you have to make your code "almost" both compatible).
For that, there are some easy steps to remember (I might forget some):
Add "@static-method" the line before statics methods are defined
Add an empty "__init__.py" file on python subfolders

I doubt it's a problem with numpy recipe, but it can, so you can add the version you want to use in buildozer.specs, or just clean the buildozer to test again.

Hope this help you, let me know :)



来源:https://stackoverflow.com/questions/46628029/kivy-app-on-android-only-loads-3-seconds-and-then-closes-itself

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!