2

我正在尝试在我直接从 kivy.org 获得的虚拟机中使用 buildozer 为简单的 python3/kivy 应用程序构建一个 apk,这是第 2 天,仍然没有运气。我有很多错误,安装了 pip,更新了 buildozer,pip 安装了 morse,pnglab,sh,appdirs,py3 的 setuptools,但现在我得到了这个错误,我必须承认它真的让我很着迷,有人知道这是怎么回事吗?我非常感谢您的回答,因为我计划有一天将机器人开发作为我的工作,谢谢。这是错误:
AttributeError: 'Context' object has no attribute 'hostpython'

和追溯:

Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals
File "/home/kivy/Desktop/TextEditor/.buildozer/android/platform/python-for android-master/pythonforandroid/toolchain.py", line 747, in <module> main()
File "/home/kivy/Desktop/TextEditor/.buildozer/android/platform/python-for android-master/pythonforandroid/toolchain.py", line 744, in main ToolchainCL()
File "/home/kivy/Desktop/TextEditor/.buildozer/android/platform/python-for android-master/pythonforandroid/toolchain.py", line 323, in __init__ getattr(self, args.command)(unknown)
File "/home/kivy/Desktop/TextEditor/.buildozer/android/platform/python-for android-master/pythonforandroid/toolchain.py", line 105, in wrapper_func build_dist_from_args(ctx, dist, dist_args)
File "/home/kivy/Desktop/TextEditor/.buildozer/android/platform/python-for android-master/pythonforandroid/toolchain.py", line 142, in build_dist_from_args build_recipes(build_order, python_modules, ctx)
File "pythonforandroid/build.py", line 560, in build_recipes recipe.build_arch(arch)
File "/home/kivy/Desktop/TextEditor/.buildozer/android/platform/python-for android-master/pythonforandroid/recipes/python2/__init__.py", line 44, in build_arch self.do_python_build(arch)
File "/home/kivy/Desktop/TextEditor/.buildozer/android/platform/python-for android-master/pythonforandroid/recipes/python2/__init__.py", line 76, in do_python_build shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch))
AttributeError: 'Context' object has no attribute 'hostpython'
# Command failed: python -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy --arch armeabi-v7a --copy-libs
#
4

3 回答 3

8

这是由新的 python-for-android 工具链(android_newbuildozer 目标使用)中的一个错误引起的。您可以通过将您的 python 版本目标添加到需求来解决它,例如requirements = kivy,python2.

于 2016-04-15T12:37:46.907 回答
2

kivy 1.9 如果您在 buildozer.spec 文件中使用 python 2 编写代码

要求 = kivy,python2

对于 python3 要求 = kivy,python3

于 2016-11-20T04:02:58.753 回答
1

实际上对于python3,要求将是

requirements = kivy,python3crystax

你需要 Crytax NDK ( https://www.crystax.net/en/android/ndk ) 而不是 android NDK

于 2016-12-14T14:29:19.940 回答