Writing my first Android app in Python and using Buildozer to package it. Because I will need to use numpy later on in the project, I tried packaging the following test code:
import numpy
import kivy
kivy.require('1.0.6')
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
However, I got the following error:
Traceback (most recent call last):
File "setup.py", line 251, in <module>
setup_package()
File "setup.py", line 243, in setup_package
setup(**metadata)
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/command/build_ext.py", line 59, in run
self.run_command('build_src')
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/command/build_src.py", line 153, in run
self.build_sources()
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/command/build_src.py", line 164, in build_sources
self.build_library_sources(*libname_info)
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/command/build_src.py", line 299, in build_library_sources
sources = self.generate_sources(sources, (lib_name, build_info))
File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/command/build_src.py", line 386, in generate_sources
source = func(extension, build_dir)
File "numpy/core/setup.py", line 686, in get_mathlib_info
raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program
STDERR:
# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy,numpy --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/kivy/Desktop/cam/.buildozer/android/platform/build
#
# 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
Also, here is my buildozer.spec file:
title = My Application
package.name = myapp
package.domain = org.test
source.dir = .
source.include_exts = py,png,jpg,kv,atlas
version = 1.0
requirements = kivy,numpy
orientation = portrait
osx.kivy_version = 1.9.1
fullscreen = 0
android.api = 19
android.sdk = 20
android.ndk = 9c
android.arch = armeabi-v7a
log_level = 2
warn_on_root = 1
Note that when I removed "import numpy" from the python code and removed "numpy" from the requirements list in the buildozer.spec file, my code was packaged perfectly. I am running this on VM Virtual Box which had Buildozer pre-installed.
Also it is not just Numpy giving me this issue- OpenCV is giving me the exact same errors. Will make separate post for that if needed.
This issue is reported in Python for Android (p4a) project here, didn't knew it's actual for stable p4a. Nevertheless, by link you can find PR that fixes issue. I didn't test it, but different people say it works.
You can try to build numpy with this fix, here's what you'll need:
Make sure you clean all left from current building process with command:
buildozer distclean
Clone p4a branch with fix using command:
git clone -b p4a_numpy_fix https://github.com/mahomahomaho/python-for-android fix-numpy
Change your buildozer.spec to use this cloned version of p4a (use your actual path):
p4a.source_dir = /home/ubuntu/p4a_numpy_fix
And run building apk again. If everything will work fine, you'll be able to build apk. If not you'll face another errors, no guarantees here :(
Related
I am using kivy.garden.mapview for my application. Everything works properly, but problems arise when I try to deploy the application to Android with Buildozer. I set "garden_requirements = mapview" in the .spec file, and I always get the same error message: "Command failed: garden install --app mapview". The command fails even when I execute it on its own. The command "buildozer android debug deploy run logcat" produces the following output:
albi#albi-VirtualBox:~/CUCINA$ buildozer android debug deploy run logcat
# 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/albi/.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-8-openjdk-amd64/jre/bin/keytool
# Install platform
# Run 'git config --get remote.origin.url'
# Cwd /home/albi/CUCINA/.buildozer/android/platform/python-for-android
https://github.com/kivy/python-for-android.git
# Run 'git branch -vv'
# Cwd /home/albi/CUCINA/.buildozer/android/platform/python-for-android
* master 1b3b0e3f [origin/master] Merge pull request #2225 from kivy/release-2020.06.02
# 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/albi/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/albi/.buildozer/android/platform/android-sdk
# Recommended android's NDK version by p4a is: 19c
# Android NDK found at /home/albi/.buildozer/android/platform/android-ndk-r19c
# Check application requirements
# Check garden requirements
# Remove directory and subdirectory /home/albi/CUCINA/.buildozer/libs
# Run 'bash -c "source venv/bin/activate && env"'
# Cwd /home/albi/CUCINA/.buildozer
SHELL=/bin/bash
SESSION_MANAGER=local/albi-VirtualBox:#/tmp/.ICE-unix/1718,unix/albi-VirtualBox:/tmp/.ICE-unix/1718
QT_ACCESSIBILITY=1
COLORTERM=truecolor
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
XDG_MENU_PREFIX=gnome-
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GTK_IM_MODULE=ibus
QT4_IM_MODULE=ibus
LC_ADDRESS=it_IT.UTF-8
GNOME_SHELL_SESSION_MODE=ubuntu
LC_NAME=it_IT.UTF-8
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
XMODIFIERS=#im=ibus
DESKTOP_SESSION=ubuntu
LC_MONETARY=it_IT.UTF-8
SSH_AGENT_PID=1649
ANDROIDAPI=27
GTK_MODULES=gail:atk-bridge
PWD=/home/albi/CUCINA/.buildozer
PACKAGES_PATH=/home/albi/.buildozer/android/packages
XDG_SESSION_DESKTOP=ubuntu
LOGNAME=albi
XDG_SESSION_TYPE=x11
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
ANDROIDNDK=/home/albi/.buildozer/android/platform/android-ndk-r19c
XAUTHORITY=/run/user/1000/gdm/Xauthority
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
WINDOWPATH=2
HOME=/home/albi
USERNAME=albi
IM_CONFIG_PHASE=1
LC_PAPER=it_IT.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=ubuntu:GNOME
VIRTUAL_ENV=/home/albi/CUCINA/.buildozer/venv
VTE_VERSION=6001
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/66ea9009_ef14_420d_ae9a_ff4590d07de8
INVOCATION_ID=5f9f2518374145c29f2f6ad18acfb7f8
MANAGERPID=1473
CLUTTER_IM_MODULE=ibus
GJS_DEBUG_OUTPUT=stderr
LESSCLOSE=/usr/bin/lesspipe %s %s
XDG_SESSION_CLASS=user
LC_IDENTIFICATION=it_IT.UTF-8
TERM=xterm-256color
LESSOPEN=| /usr/bin/lesspipe %s
USER=albi
ANDROIDMINAPI=21
GNOME_TERMINAL_SERVICE=:1.140
DISPLAY=:0
SHLVL=1
LC_TELEPHONE=it_IT.UTF-8
QT_IM_MODULE=ibus
LC_MEASUREMENT=it_IT.UTF-8
XDG_RUNTIME_DIR=/run/user/1000
PS1=(venv)
LC_TIME=it_IT.UTF-8
ANDROIDSDK=/home/albi/.buildozer/android/platform/android-sdk
JOURNAL_STREAM=9:32116
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
PATH=/home/albi/CUCINA/.buildozer/venv/bin:/home/albi/.buildozer/android/platform/apache-ant-1.9.4/bin:/home/albi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
GDMSESSION=ubuntu
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
LC_NUMERIC=it_IT.UTF-8
OLDPWD=/home/albi
_=/usr/bin/env
# Run 'pip install Kivy-Garden==0.1.1'
# Cwd None
Requirement already satisfied: Kivy-Garden==0.1.1 in ./.buildozer/venv/lib/python3.8/site-packages (0.1.1)
Requirement already satisfied: requests in ./.buildozer/venv/lib/python3.8/site-packages (from Kivy-Garden==0.1.1) (2.23.0)
Requirement already satisfied: certifi>=2017.4.17 in ./.buildozer/venv/lib/python3.8/site-packages (from requests->Kivy-Garden==0.1.1) (2020.4.5.2)
Requirement already satisfied: idna<3,>=2.5 in ./.buildozer/venv/lib/python3.8/site-packages (from requests->Kivy-Garden==0.1.1) (2.9)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in ./.buildozer/venv/lib/python3.8/site-packages (from requests->Kivy-Garden==0.1.1) (1.25.9)
Requirement already satisfied: chardet<4,>=3.0.2 in ./.buildozer/venv/lib/python3.8/site-packages (from requests->Kivy-Garden==0.1.1) (3.0.4)
# Create directory /home/albi/CUCINA/.buildozer/libs
# Install garden package mapview in buildozer_dir
# Run 'garden install --app mapview'
# Cwd /home/albi/CUCINA/.buildozer
Downloading http://github.com/kivy-garden/garden.mapview/archive/master.zip ...
Traceback (most recent call last):
File "/home/albi/CUCINA/.buildozer/venv/bin/garden", line 189, in <module>
GardenTool().main(sys.argv[1:])
File "/home/albi/CUCINA/.buildozer/venv/bin/garden", line 71, in main
options.func()
File "/home/albi/CUCINA/.buildozer/venv/bin/garden", line 109, in cmd_install
fd = self.download(opts.package)
File "/home/albi/CUCINA/.buildozer/venv/bin/garden", line 170, in download
data += buf
TypeError: can only concatenate str (not "bytes") to str
# Command failed: garden install --app mapview
# ENVIRONMENT:
# PATH = '/home/albi/CUCINA/.buildozer/venv/bin:/home/albi/.buildozer/android/platform/apache-ant-1.9.4/bin:/home/albi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
# PACKAGES_PATH = '/home/albi/.buildozer/android/packages'
# ANDROIDSDK = '/home/albi/.buildozer/android/platform/android-sdk'
# ANDROIDNDK = '/home/albi/.buildozer/android/platform/android-ndk-r19c'
# ANDROIDAPI = '27'
# ANDROIDMINAPI = '21'
# VIRTUAL_ENV = '/home/albi/CUCINA/.buildozer/venv'
# CC = '/bin/false'
# CXX = '/bin/false'
#
# 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
albi#albi-VirtualBox:~/CUCINA$
I have tried everything I found on Stack Overflow, but nothing worked. Any suggestion?
The problematic error stems from this piece of information here:
Kivy-Garden==0.1.1
I had the same issue, buildozer, for some weird reason installs Kivy-Garden version 0.1.1 which produces that error when you try to install ANY garden flower. Kivy version 1.11.1 now uses Kivy-Garden>=0.1.4 which works without issues.
If you install Kivy-Garden==0.1.1 and try to install a package, it crushes with that error. However, If you upgrade to Kivy-Garden==0.1.4. The problem is that buildozer will install Kivy-Garden==0.1.1 no matter what you do. So I tried a lot of things from downgrading buildozer to manually activating the environment that buildozer creates and upgrading garden there but when you run the buildozer command again. Buildozer will simply overwrite your upgraded garden AND install the non-working 0.1.1.
Finally I just gave up and did the one thing I COULD do at this moment. Simply fix buildozer myself:
Activate your environment(assuming you have one)
Go to where buildozer is installed. In my case this is: /home/samuel/repo/mobile/venv/finager/lib/python3.7/site-packages/buildozer-1.2.0.dev0-py3.7.egg/buildozer/__init__.py. You can find that out by checking the paths in your logs.
Now go to Line 533 and change where it says pip install Kivy-Garden==0.1.1 to pip install Kivy-Garden==0.1.4
That's it, your problem should go away now.
I hope they fix this soon as this is a pretty simple thing to do. Kivy itself requires Kivy-Garden>=0.1.4 which makes me wonder why buildozer would want 0.1.1 when it clearly doesn't work
Versions
Python: 2.7
OS: Linux Lite (Ubuntu)
Kivy: 1.10.1
Cython: 0.22
Buildozer does not proceed with the creation of the App by an error in toolchain.py and arguments --ndk-api 9.
I switched to all cython versions from 0.21 to the latest, but nothing has changed. I went in the android sdk folder and made several updates, however the problem still persists.
the error is: 'toolchain.py: error: unrecognized arguments: --ndk-api 9'
last part of log:
usage: toolchain.py [-h] [--private PRIVATE] --package PACKAGE --name NAME
[--numeric-version NUMERIC_VERSION] --version VERSION
[--orientation ORIENTATION] [--launcher] [--icon ICON]
[--permission PERMISSIONS [PERMISSIONS ...]]
[--meta-data META_DATA] [--presplash PRESPLASH]
[--presplash-color PRESPLASH_COLOR] [--wakelock]
[--window] [--blacklist BLACKLIST] [--whitelist WHITELIST]
[--add-jar ADD_JAR] [--add-aar ADD_AAR] [--depend DEPENDS]
[--sdk SDK_VERSION] [--minsdk MIN_SDK_VERSION]
[--intent-filters INTENT_FILTERS] [--service SERVICES]
[--add-source EXTRA_SOURCE_DIRS]
[--try-system-python-compile] [--no-compile-pyo] [--sign]
toolchain.py: error: unrecognized arguments: --ndk-api 9
# Command failed: /usr/bin/python -m pythonforandroid.toolchain apk --debug --bootstrap=sdl2 --dist_name myapp --name 'My Application' --version 0.1 --package org.test.myapp --android_api 19 --minsdk 9 --ndk-api 9 --private /home/dev/Modelos/testea/.buildozer/android/app --orientation portrait --window --copy-libs --arch armeabi-v7a --color=always --storage-dir="/home/dev/Modelos/testea/.buildozer/android/platform/build"
#
# 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
would anyone know the reason for this error?
for other people who may have this same problem, I put here everything I did to solve the bug.
Ok, first, this was a bug where the buildozer.spec file for some reason did not properly update the p4a files and there was also an error with the version of ndk used.
First I downloaded the r17c version of NDK. I went to the /home/dev/.buildozer/android/platform/ path and extract the downloaded file.
Then in the path /home/dev/buildozer/buildozer/default.spec I changed the branch used in p4a for the master and it looked like this:
# p4a.branch = master
I have also changed the following lines:
# (int) Android API to use
# android.api = 21
# (int) Minimum API required. You will need to set the android.ndk.api to be as low as this value.
# android.minapi = 21
# (int) Android SDK version to use
# android.sdk = 20
# (str) Android NDK version to use
# android.ndk = r17c
# (int) Android NDK API to use (optional). This is the minimum API your app will support.
# android.ndk_api = 19
Well, that initially did not change anything in the way the construction was being done and it continued to make a mistake. So I went on the path
/ home / dev / buildozer / buildozer / targets /
and in the file android.py I changed lines 17, 18 and 20 thus:
ANDROID_API = '21' #line 17
ANDROID_MINAPI = '21' #line 18
ANDROID_SDK_VERSION = '20'
ANDROID_NDK_VERSION = '17c' #line 20
APACHE_ANT_VERSION = '1.9.4'
in this same file, in the TargetAndroid class I changed lines 46 (the old name is python-for-android-new-version) and 47, the class looks like this:
class TargetAndroid (Target):
targetname = 'android_old'
p4a_directory = "python-for-android" #line 46
p4a_branch = 'master' #line 47
p4a_apk_cmd = "python build.py"
Ok, in this same path has a file called android_new.py, in the TargetAndroidNew class I changed lines 16 and 17, the class looks like this:
class TargetAndroidNew (TargetAndroid):
targetname = 'android'
p4a_branch = "master" #line 16
p4a_directory = "python-for-android" #line 17
p4a_apk_cmd = "apk --debug --bootstrap ="
extra_p4a_args = ''
Ok, this should already work, but for some reason there is another path with pretty much the same files, so I made the same changes. No path
/home/dev/buildozer/build/lib.linux-x86_64-2.7/buildozer/
I changed the default.spec file as I had done previously. And in the path
/home/dev/buildozer/build/lib.linux-x86_64-2.7/buildozer/targets/
I've changed the files android.py and android_new.pyin the same way as I previously did.
Now the buildozer performs the proper update of p4a and ndk and works correctly.
I'm currently trying to compile a simple Kivy app for use on Android. It runs in both my windows and linux environments without errors or warnings. When I go to package it using buildozer I get an error almost immediately. I did search for this error and although the title is very similar to other questions, the error is not.
Output from buildozer:
(mykivyinstall) oli#Bud: buildozer android debug
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Install platform
Traceback (most recent call last):
File "/home/oli/mykivyinstall/bin/buildozer", line 11, in <module>
sys.exit(main())
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/scripts/client.py", line 13, in main
Buildozer().run_command(sys.argv[1:])
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/__init__.py", line 1059, in run_command
self.target.run_commands(args)
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/target.py", line 92, in run_commands
func(args)
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/target.py", line 102, in cmd_debug
self.buildozer.prepare_for_build()
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/__init__.py", line 176, in prepare_for_build
self.target.install_platform()
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/targets/android.py", line 467, in install_platform
self._install_p4a()
File "/home/oli/mykivyinstall/lib/python3.6/site-packages/buildozer/targets/android.py", line 524, in _install_p4a
deps = re.findall("^install_reqs = (\[[^\]]*\])", setup, re.DOTALL | re.MULTILINE)[0]
IndexError: list index out of range
My environment:
buildozer version=0.35
cython version=0.25.2
python version=3.6.6
OS is Ubuntu=18.04
Am I mixing and matching the wrong versions of things?
This seems a like a bug in the latest version of buildozer. The solution is to edit the file "../python3.6/site-packages/buildozer/targets/android.py" and replace the line
deps = re.findall("^install_reqs = (\[[^\]]*\])", setup, re.DOTALL | re.MULTILINE)[0]
with
deps = re.findall("install_reqs = (\[[^\]]*\])", setup, re.DOTALL | re.MULTILINE)[0]
Then run buildozer -v android debug
I have been able to build an .apk file by kivy and python2.7 using buildozer, and the app works fine on phone-device. After a while, i started a new project in a new folder (together with new main.py), but when i do buildozer android debug, the Error attached keeps coming out, something with gradlew. In my previous builds, this never happens.
In this new main.py, i previously use numpy module, but this module cause Error also in the build-up. So i removed it and rewrite the code. Now another Error occurs (the Error because gradlew).
I have tried added android in the requirements. Does not work. (although i prefer to use the default buildozer.spec).
I appreciate some inputs on this.
*Also, i found some official resources, either from Github or the buildozer site are a bit inconsistent. Is there a detail resource such that i may install buildozer correctly, also the guide for the buildozer.specs?
I even not fully remember why the previous app works well..because i also bumped into several problems before the 1st App works fine.
** When i debug the new main.py in the old folder, the build process succeed.**
** (I also use the same package.name and package.domain as the 1st App) **
Thanks in advance.
STDERR:
[INFO]: STDOUT:
Unzipping /home/kivy/.gradle/wrapper/dists/gradle-3.3-all/2n0i7hqatcbtk57vvql575dbap/gradle-3.3-all.zip to /home/kivy/.gradle/wrapper/dists/gradle-3.3-all/2n0i7hqatcbtk57vvql575dbap
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.zip.ZipFile.<init>(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:157)
at org.gradle.wrapper.Install.access$400(Install.java:26)
at org.gradle.wrapper.Install$1.call(Install.java:67)
at org.gradle.wrapper.Install$1.call(Install.java:44)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)
[INFO]: STDERR:
[INFO]: COMMAND:
cd /home/kivy/Desktop/blablaapp/.buildozer/android/platform/build/dists/myapp && ./gradlew assembleDebug
[WARNING]: ERROR: ./gradlew failed!
# Command failed: /usr/bin/python -m pythonforandroid.toolchain apk --debug --bootstrap=sdl2 --dist_name myapp --name 'My Application' --version 0.1 --package org.test.myapp --android_api 19 --minsdk 9 --private /home/kivy/Desktop/sudoku_newbie/.buildozer/android/app --orientation portrait --window --copy-libs --arch armeabi-v7a --color=always --storage-dir=/home/kivy/Desktop/sudoku_newbie/.buildozer/android/platform/build
#
# 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
This error mostly occurs when you've interrupted the system when Gradle was downloading.
You can simply fix this by manually downloading gradle from https://services.gradle.org/distributions/gradle-4.4-all.zip
Then replace the gradle-4.4-all.zip.part in /your/home/path/.gradle/wrapper/dists/gradle-4.4-all/4th6d42q1kgladv9hkn2iehgi5 with the new dowloaded file
I had the same problem to solve mine I downloaded an earlier version of buildozer and it worked
[Python = 2.7]
I recently started to use kivy (newest version) to develop an app for Android. For this I use buildozer (newest version) to create the apk file. Now everything works fine on my computer even using the python-firebase module. To send data to the Firebase online database. But when I want to use the Python module python-firebase (that is based on the module requests) on my phone the app crashes after it loads for a few seconds.
For now my requirements in the buildozer.spec are plyer and kivy. If I try to add requests to this list, I get the error:
# Install requirement requests in virtualenv
# Run 'pip install --download-cache=/home/notwaka/.buildozer/cache --target=/home/notwaka/Desktop/Gps/.buildozer/applibs requests'
# Cwd /home/notwaka/Desktop/Gps/.buildozer
Usage:
pip install [options] <requirement specifier> [package-index-options] ...
pip install [options] -r <requirements file> [package-index-options] ...
pip install [options] [-e] <vcs project url> ...
pip install [options] [-e] <local project path> ...
pip install [options] <archive url/path> ...
no such option: --download-cache
# Command failed: pip install --download-cache=/home/notwaka/.buildozer/cache --target=/home/notwaka/Desktop/Gps/.buildozer/applibs requests
#
# Buildozer failed to execute the last command
Do I need to add requests to the requirements, since it is done in an example in the documentation of using buildozer? What can I do to make python-firebase working on my Android device? I have no knowledge about how to make a recipe and can't find any good documentation about this. Could making a recipe work? Has anyone tried to get Firebase working with Python on Android?
'# Check application requirements
# Run './distribute.sh -l'
# Cwd /home/notwaka/Desktop/try/.buildozer/android/platform/python-for-android
Available modules: android apsw audiostream bidi boost cherrypy c_igraph click cprotobuf cymunk django docutils ecdsa enum34 evdev ffmpeg ffmpeg2 ffpyplayer ffpyplayer_tito flask freetype gevent greenlet harfbuzz hostpython igraph itsdangerous jinja2 jpeg kivent_core kivent_cymunk kivy leveldb libevent libpq libsodium libswift libtorrent libxml2 libxslt libyaml lxml m2crypto markupsafe midistream msgpack mysql_connector netifaces numpy opencv openssl paramiko pil plyer plyvel png polygon protobuf psutil psycopg2 pyasn1 pycrypto pygame pyjnius pylibpd pyopenssl pyparsing pyqrcode python pyyaml sdl setuptools six sqlalchemy sqlite3 storm swift thrift twisted txws werkzeug wokkel zeroconf zope
# Remove directory and subdirectory /home/notwaka/Desktop/try/.buildozer/applibs
# Create directory /home/notwaka/Desktop/try/.buildozer/applibs
# Run 'bash -c "source venv/bin/activate && env"'
# Cwd /home/notwaka/Desktop/try/.buildozer
LC_PAPER=nl_NL.UTF-8
XDG_VTNR=7
LC_ADDRESS=nl_NL.UTF-8
XDG_SESSION_ID=c2
CLUTTER_IM_MODULE=xim
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/notwaka
SELINUX_INIT=YES
LC_MONETARY=nl_NL.UTF-8
GPG_AGENT_INFO=/run/user/1000/keyring-wWFm7x/gpg:0:1
VTE_VERSION=3409
SHELL=/bin/bash
TERM=xterm
LC_NUMERIC=nl_NL.UTF-8
WINDOWID=65011724
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1938
GNOME_KEYRING_CONTROL=/run/user/1000/keyring-wWFm7x
GTK_MODULES=overlay-scrollbar:unity-gtk-module
USER=notwaka
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: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:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=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:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=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:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=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:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
LC_TELEPHONE=nl_NL.UTF-8
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/run/user/1000/keyring-wWFm7x/ssh
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
VIRTUAL_ENV=/home/notwaka/Desktop/try/.buildozer/venv
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
PATH=/home/notwaka/Desktop/try/.buildozer/venv/bin:/home/notwaka/.buildozer/android/platform/apache-ant-1.9.4/bin:/home/notwaka/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
DESKTOP_SESSION=ubuntu
QT_IM_MODULE=ibus
ANDROIDAPI=19
QT_QPA_PLATFORMTHEME=appmenu-qt5
LC_IDENTIFICATION=nl_NL.UTF-8
JOB=gnome-session
PWD=/home/notwaka/Desktop/try/.buildozer
XMODIFIERS=#im=ibus
LANG=en_US.UTF-8
GNOME_KEYRING_PID=1936
GDM_LANG=en_US
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
LC_MEASUREMENT=nl_NL.UTF-8
ANDROIDNDK=/home/notwaka/.buildozer/android/platform/android-ndk-r9c
IM_CONFIG_PHASE=1
COMPIZ_CONFIG_PROFILE=ubuntu
PS1=(venv)
GDMSESSION=ubuntu
PACKAGES_PATH=/home/notwaka/.buildozer/android/packages
SESSIONTYPE=gnome-session
HOME=/home/notwaka
SHLVL=2
XDG_SEAT=seat0
LANGUAGE=en_US
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
UPSTART_INSTANCE=
UPSTART_EVENTS=started starting
ANDROIDSDK=/home/notwaka/.buildozer/android/platform/android-sdk-20
LOGNAME=notwaka
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-lqf94SPFU0
QT4_IM_MODULE=xim
LESSOPEN=| /usr/bin/lesspipe %s
ANDROIDNDKVER=r9c
UPSTART_JOB=unity-settings-daemon
INSTANCE=Unity
TEXTDOMAIN=im-config
DISPLAY=:0
XDG_RUNTIME_DIR=/run/user/1000
XDG_CURRENT_DESKTOP=Unity
GTK_IM_MODULE=ibus
LESSCLOSE=/usr/bin/lesspipe %s %s
LC_TIME=nl_NL.UTF-8
TEXTDOMAINDIR=/usr/share/locale/
LC_NAME=nl_NL.UTF-8
XAUTHORITY=/home/notwaka/.Xauthority
COLORTERM=gnome-terminal
_=/usr/bin/env
# Install distribute
# Run 'curl http://python-distribute.org/distribute_setup.py | venv/bin/python'
# Cwd /home/notwaka/Desktop/try/.buildozer
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
# Install requirement pygments in virtualenv
# Run 'pip install --download-cache=/home/notwaka/.buildozer/cache --target=/home/notwaka/Desktop/try/.buildozer/applibs pygments'
# Cwd /home/notwaka/Desktop/try/.buildozer
Usage:
pip install [options] <requirement specifier> [package-index-options] ...
pip install [options] -r <requirements file> [package-index-options] ...
pip install [options] [-e] <vcs project url> ...
pip install [options] [-e] <local project path> ...
pip install [options] <archive url/path> ...
no such option: --download-cache
# Command failed: pip install --download-cache=/home/notwaka/.buildozer/cache --target=/home/notwaka/Desktop/try/.buildozer/applibs pygments
#
# 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
'
There is an issue for Firebase working on python Kivy. See https://github.com/ozgur/python-firebase/pull/26
This is because multicore processing is not fully supported on Kivy, which is used by Firebase. This caused the crash on kivy Firebase apps.
I haven't tried the patch yet, but looking at the comments, Zkanda did good. This might be what you're looking for.
Alternatively, you can use json to download data from Firebase.
What I did to use Firebase was to use python's native Requests library to make a json call to Firebase, which they support with https.
import json, requests
url = "https://myfirebaseurl.firebaseio.com/some_database.json"
resp = requests.get(url = url, json = {'create':True})
data = resp.json()
In your buildozer.spec file, under the Requirements, include
requirements = kivy,requests,simplejson,openssl
openssl is to support https, simplejson is for json.
no such option: --download-cache
This reflects a bug in python-for-android that is now fixed. If you make buildozer re-download python-for-android, e.g. by deleting the .buildozer dir in your build directory, it should work.
You can also edit the current downloaded distribute.sh to remove the --download-cache option when calling pip.
I tried the suggested solution when encountering a similar issue with pygments, and it didn't work for me either. I increased log levels and found that pygments was being downloaded to lib64/python on my distro, whereas pip was looking for lib/python.
It appears to be related to this pip issue: https://github.com/pypa/pip/issues/3056
I added a setup.cfg file in the .buildozer folder for my app, containing:
[install]
install-purelib=$base/lib64/python
and my app now installs successfully.