App construction generates error in toolchain.py by unrecognized argument - android

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.

Related

Got error while building apk on buildozer

I am working on a kivy android app and while building the apk got the below error. The error is saying that opencv requires android sdk release version 14 or newer but when i check the version where i can find the sdk install path i can find it as 30.0.4. Below are the logs
STDOUT:
-- Looking for ccache - not found
-- OpenCV disables pkg-config to avoid using of host libraries. Consider using PKG_CONFIG_LIBDIR to specify target SYSROOT
-- libjpeg-turbo: VERSION = 1.5.3, BUILD = opencv-4.0.1-libjpeg-turbo
-- Android: fixup -g compiler option from Android toolchain
-- Update variable ANDROID_SDK from environment: /root/.buildozer/android/platform/android-sdk
CMake Error at cmake/android/OpenCVDetectAndroidSDK.cmake:176 (message):
Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer.
Use BUILD_ANDROID_PROJECTS=OFF to prepare Android project files without
building them
Call Stack (most recent call first):
CMakeLists.txt:780 (include)
-- Configuring incomplete, errors occurred!
See also "/home/myapp/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/opencv/armeabi-v7a__ndk_target_21/opencv/build/CMakeFiles/CMakeOutput.log".
See also "/home/myapp/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/opencv/armeabi-v7a__ndk_target_21/opencv/build/CMakeFiles/CMakeError.log".
STDERR:
# Command failed: /usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=python3,kivy,numpy,python-opencv,matplotlib,datetime,opencv==master --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/myapp/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21
# ENVIRONMENT:
# HOSTNAME = '06dd908deae1'
# PWD = '/home/myapp'
# HOME = '/root'
# 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:'
# LESSCLOSE = '/usr/bin/lesspipe %s %s'
# TERM = 'xterm'
# LESSOPEN = '| /usr/bin/lesspipe %s'
# SHLVL = '1'
# PATH = '/root/.buildozer/android/platform/apache-ant-1.9.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin/'
# OLDPWD = '/home'
# _ = '/root/.local/bin/buildozer'
# LC_CTYPE = 'C.UTF-8'
# PACKAGES_PATH = '/root/.buildozer/android/packages'
# ANDROIDSDK = '/root/.buildozer/android/platform/android-sdk'
# ANDROIDNDK = '/root/.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
I checked the sdk version under below path
/root/.buildozer/android/platform/android-sdk/platform-tools/source.properties
and it shows Pkg.UserSrc=false & Pkg.Revision=30.0.4
I have update the builozer.spec as below:
android.sdk = 30.0.4
# (str) Android NDK version to use
android.ndk = 19c
# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
#android.ndk_api = 21
# (bool) Use --private data storage (True) or --dir public storage (False)
#android.private_storage = True
# (str) Android NDK directory (if empty, it will be automatically downloaded.)
#android.ndk_path =
# (str) Android SDK directory (if empty, it will be automatically downloaded.)
android.sdk_path = /root/.buildozer/android/platform/android-sdk
Need help on how to fix this!!

Kivy garden mapview deploying error with Buildozer

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

Buildozer Numpy RuntimeError: Broken toolchain: cannot link a simple C program

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 :(

Facebook Buck: BUILD FAILED: No native platforms detected. Probably Android NDK is not configured properly

I am trying to build Android app using the facebook's buck build system but I am getting Build Failed error.
I am getting this same error on both MAC as well as WINDOWS
buckconfig file
[cache]
mode = dir
[cxx]
default_platform = iphonesimulator-x86_64
cflags = -g -std=c11
cxxflags = -g -std=c++14
# Many ARC APIs don't compile with separate preprocess and compile.
combined_preprocess_and_compile = true
[alias]
demo_app_android = //android:demo-app
demo_app_ios = //ios:BuckDemoApp
[apple]
xctool_zip_target = //third-party/ios/xctool:xctool-minimal-zip
[ndk]
ndk_version = 16.1.4479499
app_platform = android-26
[android]
build_tools_version = 26.0.2
target = Google Inc.:Google APIs:26
[java]
src_roots = /android/java/
source_level = 7
target_level = 7
[project]
default_android_manifest = //android/AndroidManifest.xml
ignore = .buckd, \
.hg, \
.git, \
.idea, \
buck-cache, \
buck-out, \
Environment Variables:
$ env | grep ANDROID_
ANDROID_HOME=<path>/Android/sdk
ANDROID_NDK_REPOSITORY=<path>/Android/sdk/ndk-bundle
ANDROID_SDK=<path>/Library/Android/sdk
Error Stack Trace:
Building: finished in 0.0 sec
Total time: 0.0 sec
BUILD FAILED: No native platforms detected. Probably Android NDK is not configured properly.
I am not getting that what I am missing. Appreciate your help.
Thanks
Try older version of NDK (15 or older) and make sure /Android/sdk/ndk-bundle contains a directory with that version so it looks like /Android/sdk/ndk-bundle/android-ndk-r15.
I had the same error when trying to build the sample Android APP. I tried several things to clearly understand the behaviour of the .buckconfig settings and environment variables.
Set ndk_path
you can set ndk path directly. I've set this variable instead of setting ndk_version(such as 'r10e') Keep in mind that
The environment variables ANDROID_NDK and NDK_HOME both supercede
the buckconfig setting.
Create a repo folder (recommended)
Download ndk bundle and unzip it into a folder that serves as a repository folder and set it to ANDROID_NDK_REPOSITORY env var. So the path can be used to get the correct ndk version. In this case only thing you have to do is setting the version of NDK bundle and buck will automatically get the right version for you.
Currently there is error with Buck with the Java9.
Just to add more.
If you are using java9 then downgrade to java8 as buck uses the sun/misc/BASE64Encoder which is removed in java9.
To keep versions of java8 and java9 in mac. I have implemented below command lines in .bash_profile.
export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
export JAVA_9_HOME=$(/usr/libexec/java_home -v9)
alias java8='export JAVA_HOME=$JAVA_8_HOME'
alias java9='export JAVA_HOME=$JAVA_9_HOME'
#default java8
export JAVA_HOME=$JAVA_8_HOME

tensorflow porting to android devices

I have a question about tensorflow porting to android devices. When I was in centos, using bazel compiler generated apk file, suggesting the following error:
ERROR: /data/tensorflow-master/WORKSPACE:37:1: syntax error at 'tf_workspace': expected,
ERROR: /data/tensorflow-master/WORKSPACE:44:1: non-keyword arg after keyword arg.
ERROR: error loading package 'external': Failed to parse WORKSPACE file.
INFO: Elapsed time: 0.242s
The following is the 37-44 line of the WORKSPACE file:
Please add all new TensorFlow dependencies in workspace.bzl.
37 tf_workspace ()
38
39 new_http_archive (
40 name = "inception5h",
41 build_file = "models.BUILD",
42 url = "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip",
43 sha256 = "d13569f6a98159de37e92e9c8ec4dae8f674fbf475f69fe6199b514f756d4364"
44)
I ask you have encountered similar problems? please help me.
I was facing the same problem, this is how I fixed it:
# Uncomment and update the paths in these entries to build the Android demo.
android_sdk_repository(
name = "androidsdk",
api_level = 24,
# # Ensure that you have the build_tools_version below installed in the
# # SDK manager as it updates periodically.
build_tools_version = "25.0.3",
# # Replace with path to Android SDK on your system
path = "/home/yours/Android/Sdk/",
) #my mistake #) --> )
#
# Android NDK r12b is recommended (higher may cause issues with Bazel)
android_ndk_repository(
name="androidndk",
path="/home/yours/android-ndk-r12b/",
# # This needs to be 14 or higher to compile TensorFlow.
# # Note that the NDK version is not the API level.
api_level=14)

Categories

Resources