I wrote an extremely simple app with Kivy. The main.py file is
import kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
import numpy as np
class MyGrid(Widget):
measurement_output = ObjectProperty(None)
measurement_btn = ObjectProperty(None)
def measure_btn(self):
self.measurement_output.text = 'Just a random number for testing: ' + str(round(np.random.rand()*100))
class MyApp(App):
def build(self):
return MyGrid()
if __name__ == "__main__":
MyApp().run()
In my computer this works fine. Now I am trying to take it to my Android phone using Buildozer but cannot make it.
My starting point was this Kivy guide. I installed Buildozer with pip3 install buildozer and everything went fine. After that I installed all the dependencies as is detailed in this link. I have also done what is in the python-for-android for the errors related to java version. This last thing of java 8 broke a previous problem with the Android SDK which was again solved with sudo apt install android-sdk and the java error began again. So now I am trapped in a circle it seems, when I fix the java version I get the [ERROR]: Build failed: Requested API target 27 is not available, install it with the SDK android tool. and when I fix this error I get the current error.
I have already seen many other issues here on GitHub with no success.
alf@alf-Lenovo:~/Desktop/kivy_test$ buildozer android debug deploy run
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.7 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
# -> found at /usr/bin/git
# Search for Cython (cython)
# -> found at /home/alf/.local/bin/cython
# Search for Java compiler (javac)
# -> found at /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
# -> found at /usr/lib/jvm/java-11-openjdk-amd64/bin/keytool
# Install platform
# Run 'git config --get remote.origin.url'
# Cwd /home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android
https://github.com/kivy/python-for-android.git
# Run 'git branch -vv'
# Cwd /home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android
* master 17dfa6a0 [origin/master] Merge pull request #2174 from kivy/release-2020.04.29
# Run '/usr/bin/python3 -m pip install -q --user \'appdirs\' \'colorama>=0.3.3\' \'jinja2\' \'six\' \'enum34; python_version<"3.4"\' \'sh>=1.10; sys_platform!="nt"\' \'pep517<0.7.0"\' \'toml\''
# Cwd None
# Apache ANT found at /home/alf/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/alf/.buildozer/android/platform/android-sdk
# Recommended android's NDK version by p4a is: 19c
# Android NDK found at /home/alf/.buildozer/android/platform/android-ndk-r19c
# Check application requirements
# Check garden requirements
# Compile platform
# Run '/usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=python3,kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/alf/Desktop/kivy_test/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21'
# Cwd /home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android
/home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py:84: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
[INFO]: Will compile for the following archs: armeabi-v7a
[INFO]: Found Android API target in $ANDROIDAPI: 27
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1231, in <module>
main()
File "/home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
ToolchainCL()
File "/home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 688, in __init__
getattr(self, command)(args)
File "/home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 144, in wrapper_func
ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir,
File "/home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 296, in prepare_build_environment
apis = get_available_apis(self.sdk_dir)
File "/home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 73, in get_available_apis
targets = get_targets(sdk_dir)
File "/home/alf/Desktop/kivy_test/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 61, in get_targets
targets = avdmanager('list', 'target').stdout.decode('utf-8').split('\n')
File "/usr/local/lib/python3.8/dist-packages/sh.py", line 1549, in __call__
return RunningCommand(cmd, call_args, stdin, stdout, stderr)
File "/usr/local/lib/python3.8/dist-packages/sh.py", line 793, in __init__
self.wait()
File "/usr/local/lib/python3.8/dist-packages/sh.py", line 849, in wait
self.handle_command_exit_code(exit_code)
File "/usr/local/lib/python3.8/dist-packages/sh.py", line 877, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/alf/.buildozer/android/platform/android-sdk/tools/bin/avdmanager list target
STDOUT:
STDERR:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:213)
at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
# Command failed: /usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=python3,kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/alf/Desktop/kivy_test/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21
# ENVIRONMENT:
# SHELL = '/bin/bash'
# SESSION_MANAGER = 'local/alf-Lenovo:@/tmp/.ICE-unix/1061,unix/alf-Lenovo:/tmp/.ICE-unix/1061'
# QT_ACCESSIBILITY = '1'
# COLORTERM = 'truecolor'
# XDG_CONFIG_DIRS = '/etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg'
# XDG_SESSION_PATH = '/org/freedesktop/DisplayManager/Session0'
# XDG_MENU_PREFIX = 'xfce-'
# CLUTTER_BACKEND = 'x11'
# LANGUAGE = 'en_US'
# TERMINATOR_DBUS_PATH = '/net/tenshu/Terminator2'
# LC_ADDRESS = 'es_AR.UTF-8'
# LC_NAME = 'es_AR.UTF-8'
# SSH_AUTH_SOCK = '/run/user/1000/keyring/ssh'
# TERMINATOR_UUID = 'urn:uuid:f8609dc8-6140-4197-b2e9-bd0daf0660ab'
# DESKTOP_SESSION = 'xubuntu'
# LC_MONETARY = 'es_AR.UTF-8'
# SSH_AGENT_PID = '1135'
# XDG_SEAT = 'seat0'
# PWD = '/home/alf/Desktop/kivy_test'
# LOGNAME = 'alf'
# XDG_SESSION_DESKTOP = 'xubuntu'
# QT_QPA_PLATFORMTHEME = 'gtk2'
# XDG_SESSION_TYPE = 'x11'
# PANEL_GDK_CORE_DEVICE_EVENTS = '0'
# GPG_AGENT_INFO = '/run/user/1000/gnupg/S.gpg-agent:0:1'
# XAUTHORITY = '/home/alf/.Xauthority'
# XDG_GREETER_DATA_DIR = '/var/lib/lightdm-data/alf'
# GDM_LANG = 'en_US'
# HOME = '/home/alf'
# LC_PAPER = 'es_AR.UTF-8'
# 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=30;41: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:*.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:*.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:'
# XDG_CURRENT_DESKTOP = 'XFCE'
# VTE_VERSION = '6001'
# XDG_SEAT_PATH = '/org/freedesktop/DisplayManager/Seat0'
# TERMINATOR_DBUS_NAME = 'net.tenshu.Terminator21a9d5db22c73a993ff0b42f64b396873'
# LESSCLOSE = '/usr/bin/lesspipe %s %s'
# XDG_SESSION_CLASS = 'user'
# TERM = 'xterm-256color'
# LC_IDENTIFICATION = 'es_AR.UTF-8'
# GTK_OVERLAY_SCROLLING = '0'
# LESSOPEN = '| /usr/bin/lesspipe %s'
# USER = 'alf'
# DISPLAY = ':0.0'
# SHLVL = '1'
# LC_TELEPHONE = 'es_AR.UTF-8'
# LC_MEASUREMENT = 'es_AR.UTF-8'
# XDG_VTNR = '7'
# XDG_SESSION_ID = 'c2'
# XDG_RUNTIME_DIR = '/run/user/1000'
# LC_TIME = 'es_AR.UTF-8'
# XDG_DATA_DIRS = '/usr/share/xubuntu:/usr/share/xfce4:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/usr/share'
# PATH = '/home/alf/.buildozer/android/platform/apache-ant-1.9.4/bin:/home/alf/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
# GDMSESSION = 'xubuntu'
# DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/user/1000/bus'
# LC_NUMERIC = 'es_AR.UTF-8'
# _ = '/usr/local/bin/buildozer'
# PACKAGES_PATH = '/home/alf/.buildozer/android/packages'
# ANDROIDSDK = '/home/alf/.buildozer/android/platform/android-sdk'
# ANDROIDNDK = '/home/alf/.buildozer/android/platform/android-ndk-r19c'
# ANDROIDAPI = '27'
# ANDROIDMINAPI = '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
In an early stage of the command execution the log shows:
# Search for Java compiler (javac)
# -> found at /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
# -> found at /usr/lib/jvm/java-11-openjdk-amd64/bin/keytool
I am really new to all this. I see that the javac compiler has the right version (i.e. java-8) however the keytool (I don't konw what this is) has the version 11, which is the one I had in my computer before downgrading to java 8. Might this be the problem?
Versions
$ buildozer --version
returnsDescription
I wrote an extremely simple app with Kivy. The
main.py
file isand the
my.kv
file isIn my computer this works fine. Now I am trying to take it to my Android phone using Buildozer but cannot make it. My starting point was this Kivy guide. I installed Buildozer with
pip3 install buildozer
and everything went fine. After that I installed all the dependencies as is detailed in this link. I have also done what is in the python-for-android for the errors related to java version. This last thing of java 8 broke a previous problem with the Android SDK which was again solved withsudo apt install android-sdk
and the java error began again. So now I am trapped in a circle it seems, when I fix the java version I get the[ERROR]: Build failed: Requested API target 27 is not available, install it with the SDK android tool.
and when I fix this error I get the current error.I have already seen many other issues here on GitHub with no success.
buildozer.spec
Command:
Spec file:
Logs
In an early stage of the command execution the log shows:
I am really new to all this. I see that the javac compiler has the right version (i.e. java-8) however the keytool (I don't konw what this is) has the version 11, which is the one I had in my computer before downgrading to java 8. Might this be the problem?