Android上的Kivy应用只会加载(3秒),然后自行关闭 [英] Kivy app on android only loads (3 seconds) and then closes itself

查看:121
本文介绍了Android上的Kivy应用只会加载(3秒),然后自行关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已解决的问题:

我想问一下一个使用以下工具构建的Kivy-Python应用程序: Oracle虚拟机上的buildozer.该应用程序是用 Windows,使用kivy python 3 ,并取决于numpy,还有一些 .png文件.

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.

构建apk文件:

Building the apk file :

在虚拟机Linux终端上,我已经设置了项目文件夹 包含主文件main.py,然后运行:

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

此行的过程花费了相当长的时间. apk文件的大小 11MB.插入电话后,我就跑了(在VM Linux终端上):

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?

我在VM终端中看到的python是python 2.7.13 代码是用python 3编写的. 这是问题吗?如果是的话 是解决方案吗?

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.

解决方案:

解决方案是重写代码,使其可以在python 2.7中工作.现在,该代码可在Python2和Python3中使用.然后,我使用此编辑的main.py构建apk.现在,它不会崩溃.

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的日志,但您可以添加一些信息以进行更多过滤.)

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.).

我也遇到了与此配置类似的问题(计算机上的python3和android上的python2,是的,您必须使代码几乎"都兼容).
为此,有一些简单的步骤要记住(我可能会忘记一些):
在定义静态方法之前,在该行中添加"@ static-method"
在python子文件夹上添加一个空的"__init__.py"文件

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

我怀疑这是numpy配方的问题,但是可以,因此您可以在buildozer.specs中添加要使用的版本,或者只是清洁buildozer以便再次测试.

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 :)

这篇关于Android上的Kivy应用只会加载(3秒),然后自行关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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