Kivy application does not work on Android

随声附和 提交于 2019-12-02 07:40:02

I've used python-for android tool and faced with the same errors. But in my case, app didn't run at all - crashed from splash screen. Finally, I've found a solution. You can try the same way.

So my pipeline was python3 + python-for-android (p4a tool, python-for-android, from master branch) + kivy (1.10.1)

There is a file "_android.pyx" for android building recipe (full list of avaliable p4a recipes you can see by command p4a recipes). This file is, possibly, used by Buildozer, and exactly used by P4A during APK building procedure. You need to fix it.

You may find it's location in Ubuntu (for example) via:

sudo updatedb
locate _android.pyx

It's path should be something like:

~/.local/lib/python3.6/site-packages/pythonforandroid/recipes/android/src/android/_android.pyx

There should be a string:

python_act = autoclass(JAVA_NAMESPACE.decode('utf-8') + u'.PythonActivity')

so you should change it - something like this:

python_act = autoclass(str(JAVA_NAMESPACE) + u'.PythonActivity'),

or just use some hardcode:

python_act = autoclass("org/kivy/android/PythonActivity")

Or there might be the other decode() usage in sources.

The reason: differences between Python2 and Python3 - the decode() method is usable on the equivalent binary data type in either Python 2 or 3, but it can’t be used by the textual data type consistently between Python 2 and 3 because str in Python 3 doesn’t have the method decode function has different realisation in Python3. More details are here: pyporting features issues p4a's github

Hope, it will help you somehow.

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