Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors packaging app for android using ubuntu and buildozer

PREREQUISITES

I'm trying to figure out how to package python apps using buildozer. After wasting many hours attempting to do so I've reached a point where I've got stuck, here's a little summary of the steps I've followed:

  • Downloaded ubuntu16.04 x64 .vdi, extracted and run with virtualbox.

  • sudo apt-get update

  • sudo apt-get upgrade
  • sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev git
  • sudo apt-get install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386
  • sudo apt install curl git
  • curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
  • echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
  • echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
  • echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
  • pyenv install 3.6.2
  • pyenv global 3.6.2
  • pip install virtualenv
  • pip install --upgrade pip
  • Created shared folder with write permissions+automont and reboot
  • sudo usermod -aG vboxsf osboxes && reboot
  • cd /media/sf_android_apps/
  • pip install cython==0.21
  • pip install buildozer

At this point... "theorically" everything should be ready to bake apks, so let's try to build a little minimal hello world app:

APP + SPEC

hello_world.py:

print('hello android!!!')

buildozer.spec:

Default content but changing the log_level

...
log_level = 2
...

ERRORS

1) When I try to build the app from the virtualbox shared folder location I'll get:

osboxes@osboxes:/media/sf_android_apps$ buildozer -v android debug
...
Traceback (most recent call last):
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/media/sf_android_apps/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1073, in <module>
    main()
  File "/media/sf_android_apps/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1067, in main
    ToolchainCL()
  File "/media/sf_android_apps/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 576, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/media/sf_android_apps/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 151, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/media/sf_android_apps/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 200, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/media/sf_android_apps/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 548, in build_recipes
    recipe.prepare_build_dir(arch.arch)
  File "/media/sf_android_apps/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 505, in prepare_build_dir
    self.unpack(arch)
  File "/media/sf_android_apps/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py", line 404, in unpack
    sh.tar('xf', extraction_filename)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 1427, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 774, in __init__
    self.wait()
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 792, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_2: 

  RAN: /bin/tar xf /media/sf_android_apps/.buildozer/android/platform/build/packages/sdl2_image/SDL2_image-2.0.4.tar.gz

  STDOUT:


  STDERR:
/bin/tar: SDL2_image-2.0.4/Xcode/Frameworks/webp.framework/Resources: Cannot create symlink to ‘Versions/Current/Resources’: Read-only file system
/bin/tar: SDL2_image-2.0.4/Xcode/Frameworks/webp.framework/webp: Cannot create symlink to ‘Versions/Current/webp’: Read-only file system
/bin/tar: SDL2_image-2.0.4/Xcode/Frameworks/webp.framework/Headers: Cannot create symlink to ‘Versions/Current/Headers’: Read-only file system
/bin/tar: SDL2_image-2.0.4/Xcode/Frameworks/webp.framework/Versions/Current: Cannot create symlink to ‘A’: Read-only file system
/bin/tar: Exiting with failure status due to previous errors

# Command failed: /home/osboxes/.pyenv/versions/3.6.2/bin/python3.6 -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir="/media/sf_android_apps/.buildozer/android/platform/build" --ndk-api=21
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

2) And when I try to do the same from a normal folder location I'll get:

osboxes@osboxes:~/foo$ buildozer -v android debug
...
[INFO]:    -> running autogen.sh
Exception in thread background thread for pid 16689:                           
Traceback (most recent call last):
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 1540, in wrap
    fn(*args, **kwargs)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 2459, in background_thread
    handle_exit_code(exit_code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 2157, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_127: 

  RAN: /home/osboxes/foo/.buildozer/android/platform/build/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh

  STDOUT:
/home/osboxes/foo/.buildozer/android/platform/build/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh: 2: exec: autoreconf: not found


  STDERR:


Traceback (most recent call last):
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/osboxes/foo/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1073, in <module>
    main()
  File "/home/osboxes/foo/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1067, in main
    ToolchainCL()
  File "/home/osboxes/foo/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 576, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/home/osboxes/foo/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 151, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/osboxes/foo/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 200, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/home/osboxes/foo/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 562, in build_recipes
    recipe.build_arch(arch)
  File "/home/osboxes/foo/.buildozer/android/platform/python-for-android/pythonforandroid/recipes/libffi/__init__.py", line 33, in build_arch
    shprint(sh.Command('./autogen.sh'), _env=env)
  File "/home/osboxes/foo/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 178, in shprint
    for line in output:
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 863, in next
    self.wait()
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 792, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_127: 

  RAN: /home/osboxes/foo/.buildozer/android/platform/build/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh

  STDOUT:
/home/osboxes/foo/.buildozer/android/platform/build/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/autogen.sh: 2: exec: autoreconf: not found


  STDERR:

# Command failed: /home/osboxes/.pyenv/versions/3.6.2/bin/python3.6 -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/osboxes/foo/.buildozer/android/platform/build" --ndk-api=21
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

QUESTION

Do you know how to proceed here so I'll be able to succeed baking this little hello world app for android using buildozer?

ANOTHER UNSUCCESSFUL ATTEMPTS

Attempt1:

i've tested @Ronald Saunfe answer so I've downgraded to 0.32 but no luck neither

osboxes@osboxes:~/foo$ pwd
/home/osboxes/foo
osboxes@osboxes:~/foo$ buildozer android clean
osboxes@osboxes:~/foo$ pip install buildozer==0.32

this is the error I've got:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

PYTHON-FOR-ANDROID ERROR! SEE BELOW FOR SOLUTION:

You are trying to run an old version of python-for-android via
distribute.sh. However, python-for-android has been rewritten and no
longer supports the distribute.sh interface.

If you are using buildozer, you should:
- upgrade buildozer to the latest version (at least 0.30)
- delete the .buildozer folder in your app directory (the same directory that has your buildozer.spec)
- run buildozer again as normal

If you are not using buildozer, see
https://github.com/kivy/python-for-android/blob/master/README.md for
instructions on using the new python-for-android
toolchain. Alternatively, you can get the old toolchain from the
'old_toolchain' branch at
https://github.com/kivy/python-for-android/tree/old_toolchain .

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Command failed: ./distribute.sh -l
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

Attempt2:

Same than attempt1 but in this case I've removed both .buildozer from /home/osboxes and /home/osboxes/foo, this will also end up giving an error:

building 'jnius' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/jnius
ccache arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/osboxes/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -DNDEBUG -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/osboxes/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -fPIC -I/home/osboxes/foo/.buildozer/android/platform/python-for-android/build/python-install/include/python2.7 -c jnius/jnius.c -o build/temp.linux-x86_64-2.7/jnius/jnius.o
arm-linux-androideabi-gcc: error: jnius/jnius.c: No such file or directory
arm-linux-androideabi-gcc: fatal error: no input files
compilation terminated.
error: command 'ccache' failed with exit status 1
Traceback (most recent call last):
  File "/home/osboxes/.pyenv/versions/3.6.2/bin/cython", line 11, in <module>
    load_entry_point('Cython==0.21', 'console_scripts', 'cython')()
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Main.py", line 632, in setuptools_main
    return main(command_line = 1)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Main.py", line 649, in main
    result = compile(sources, options)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Main.py", line 624, in compile
    return compile_multiple(source, options)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Main.py", line 602, in compile_multiple
    result = run_pipeline(source, options, context=context)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Main.py", line 439, in run_pipeline
    err, enddata = Pipeline.run_pipeline(pipeline, source)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Pipeline.py", line 328, in run_pipeline
    data = phase(data)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Pipeline.py", line 54, in generate_pyx_code_stage
    module_node.process_implementation(options, result)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/ModuleNode.py", line 111, in process_implementation
    self.generate_c_code(env, options, result)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/ModuleNode.py", line 328, in generate_c_code
    self.body.generate_function_definitions(env, code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Nodes.py", line 398, in generate_function_definitions
    stat.generate_function_definitions(env, code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Nodes.py", line 398, in generate_function_definitions
    stat.generate_function_definitions(env, code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Nodes.py", line 1859, in generate_function_definitions
    self.generate_function_body(env, code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Nodes.py", line 1628, in generate_function_body
    self.body.generate_execution_code(code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Nodes.py", line 404, in generate_execution_code
    stat.generate_execution_code(code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Nodes.py", line 6610, in generate_execution_code
    fresh_finally_clause().generate_execution_code(code)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/site-packages/Cython/Compiler/Nodes.py", line 6598, in fresh_finally_clause
    node_copy = copy.deepcopy(node)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 280, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 215, in _deepcopy_list
    append(deepcopy(a, memo))
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 280, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 280, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 280, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 280, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 280, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 150, in deepcopy
    y = copier(x, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 240, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 297, in _reconstruct
    item = deepcopy(item, memo)
  File "/home/osboxes/.pyenv/versions/3.6.2/lib/python3.6/copy.py", line 169, in deepcopy
    rv = reductor(4)
TypeError: can't pickle Argument objects
/home/osboxes/foo/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)
running build_ext
building 'jnius' extension
ccache arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/osboxes/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -DNDEBUG -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/osboxes/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -fPIC -I/home/osboxes/foo/.buildozer/android/platform/python-for-android/build/python-install/include/python2.7 -c jnius/jnius.c -o build/temp.linux-x86_64-2.7/jnius/jnius.o
arm-linux-androideabi-gcc: error: jnius/jnius.c: No such file or directory
arm-linux-androideabi-gcc: fatal error: no input files
compilation terminated.
error: command 'ccache' failed with exit status 1
# Command failed: ./distribute.sh -m "kivy" -d "myapp"
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2
like image 362
BPL Avatar asked Feb 10 '19 22:02

BPL


People also ask

What is Buildozer Android clean?

Buildozer is a tool that aim to package mobiles application easily. It automates the entire build process, download the prerequisites like python-for-android, Android SDK, NDK, etc.

Can we use Buildozer in Windows?

Buildozer currently works only in Linux and macOS (You can still use it on Windows via WSL), and can significantly simplify the apk build. This creates a buildozer. spec file controlling your build configuration. You should edit it appropriately with your app name etc.


1 Answers

I am currently using Buildozer but this may be a work around for some

buildozer android clean
sudo pip install buildozer==0.32
sudo pip install cython==0.21
buildozer android debug
like image 181
Ronald Saunfe Avatar answered Sep 19 '22 14:09

Ronald Saunfe