So I'm trying to convert my python code to a .apk file using buildozer, but buildozer isn't working. when I run buildozer -v android debug
, this is what buildozer says:
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Search for Git (git)
# -> found at /usr/bin/git
# Search for Cython (cython)
# -> found at /home/spyridon/.local/bin/cython
# Search for Java compiler (javac)
# -> found at /opt/jdk-13/bin/javac
#
Search for Java keytool (keytool)
# -> found at /usr/lib/jvm/java-17-openjdk-amd64/bin/keytool
# Install platform
# Run ['git', 'config', '--get', 'remote.origin.url']
# Cwd /home/spyridon/kivy-test/.buildozer/android/platform/python-for-android
https://github.com/kivy/python-for-android.git
# Run ['git', 'branch', '-vv']
# Cwd /home/spyridon/kivy-test/.buildozer/android/platform/python-for-android
* master 957a3e5f [origin/master] Merge pull request #2959 from kivy/release-2024.01.21
# Run ['/usr/bin/python3', '-m', 'pip', 'install', '-q', '--user', 'appdirs', 'colorama>=0.3.3', 'jinja2', 'sh>=1.10, <2.0; sys_platform!="win32"', 'build', 'toml', 'packaging', 'setuptools']
# Cwd None`
error: externally-managed-environment
× This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
# Command failed: ['/usr/bin/python3', '-m', 'pip', 'install', '-q', '--user', 'appdirs', 'colorama>=0.3.3', 'jinja2', 'sh>=1.10, <2.0; sys_platform!="win32"', 'build', 'toml', 'packaging', 'setuptools']
# ENVIRONMENT:
# SHELL = '/bin/bash'
# SESSION_MANAGER = 'local/tubit:@/tmp/.ICE-unix/2098,unix/tubit:/tmp/.ICE-unix/2098'
# QT_ACCESSIBILITY = '1'
# XDG_CONFIG_DIRS = '/etc/xdg/xdg-ubuntu:/etc/xdg'
# SSH_AGENT_LAUNCHER = 'openssh'
# XDG_MENU_PREFIX = 'gnome-'
# GNOME_DESKTOP_SESSION_ID = 'this-is-deprecated' `# TERMINAL_EMULATOR = 'JetBrains-JediTerm' `# GNOME_KEYRING_CONTROL = '/run/user/1000/keyring' `# JAVA_HOME = '/usr/lib/jvm/java-1.6.0-openjdk-i386' `# GNOME_SHELL_SESSION_MODE = 'ubuntu' `# SSH_AUTH_SOCK = '/run/user/1000/keyring/ssh' `# TERM_SESSION_ID = '98701776-69a9-494f-b47e-d419c040338c' `# XMODIFIERS = '@im=ibus' `# DESKTOP_SESSION = 'ubuntu' `# GTK_MODULES = 'gail:atk-bridge' `# PWD = '/home/spyridon/kivy-test' `# XDG_SESSION_DESKTOP = 'ubuntu' `# LOGNAME = 'spyridon' `# XDG_SESSION_TYPE = 'wayland' `# SYSTEMD_EXEC_PID = '2311' `# XAUTHORITY = '/run/user/1000/.mutter-Xwaylandauth.7XTAM2' `# HOME = '/home/spyridon' `# USERNAME = 'spyridon' `# IM_CONFIG_PHASE = '1' `# LANG = 'en_US.UTF-8' `# LS_COLORS = 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.swp=00;90:*.tmp=00;90:*.dpkg-dist=00;90:*.dpkg-old=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:' `# XDG_CURRENT_DESKTOP = 'ubuntu:GNOME' `# WAYLAND_DISPLAY = 'wayland-0' `# INVOCATION_ID = 'ce6fdb0b15144166ae79e2e47acf9c0f'
# MANAGERPID = '1871'
# GNOME_SETUP_DISPLAY = ':1'
# LESSCLOSE = '/usr/bin/lesspipe %s %s'
# XDG_SESSION_CLASS = 'user'
# TERM = 'xterm-256color'
# LESSOPEN = '| /usr/bin/lesspipe %s'
# USER = 'spyridon'
# DISPLAY = ':0'
# SHLVL = '1'
# QT_IM_MODULE = 'ibus'
# XDG_RUNTIME_DIR = '/run/user/1000'
# DEBUGINFOD_URLS = 'https://debuginfod.ubuntu.com '
# FIG_JETBRAINS_SHELL_INTEGRATION = '1'
# JOURNAL_STREAM = '8:33121'
# XDG_DATA_DIRS = '/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop'
# PATH = '/home/spyridon/.buildozer/android/platform/apache-ant-1.9.4/bin:/home/spyridon/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/lib/jvm/java-1.6.0-openjdk-i386/bin:/home/spyridon/.local/bin/'
# GDMSESSION = 'ubuntu'
# DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/user/1000/bus'
# GIO_LAUNCHED_DESKTOP_FILE_PID = '3781'
# OLDPWD = '/home/spyridon/kivy-test/bin' #
_ = '/home/spyridon/.local/bin/buildozer'
# 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
I tried upgrading buildozer, but that didn't fix it. I tried running different variations of buildozer android debug
, same error message. Tried inside and outside of virtual environments, but nothing works! I tried researching fixes, found one. That fix raised an error too. Help!!!!!!
I Finally was able to fix it. I just disabled the externally managed message by running: sudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.old
, and then from there I had to install openjdk, which I did by running: sudo apt install default-jdk
and then I had to install cython (harder then you might think)
EDIT: Finally gave up on buildozer. I'm using BeeWare now, and it's working much better. (Can be found here)