Konrad Konrad - 2 months ago 47
Python Question

Kivy Buildozer AttributeError: 'Context' object has no attribute 'hostpython'

I'm trying to build an apk for a simple python3/kivy app using buildozer in the virtual machine I got straight from kivy.org, this is day2 and still no luck. I had many errors, instaled pip, updated buildozer, pip installed morse, pnglab, sh, appdirs, setuptools for py3, but now I got this error and I must admit it really got me, anyone know what is this about? I would very much apreciate an answer as I am planning to make droid development my job some day, thank you. This is the error:

AttributeError: 'Context' object has no attribute 'hostpython'

And the traceback:

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


This arises from a bug in the new python-for-android toolchain (which the android_new buildozer target uses). You can work around it by adding your python version target to the requirements, e.g. requirements = kivy,python2.