Kivy Buildozer Requirements Error with Python 3 - android

I'm trying to create an app for android using buildozer that needs to use OpenCV and therefore python 3(Due to the fact that OpenCV is only compatible with python 3+). But, when I pass buildozer -v android_new debug or buildozer android_new release or buildozer android_new debug deploy run logcat, it returns the same error:
Command failed: python -m pythonforandroid.toolchain --color=always --storage-dir=/home/kivy/KivyApp/.buildozer/android/platform/build create --dist_name=myapp21 --bootstrap=sdl2 --requirements=kivy,opencv,python3 --arch armeabi-v7a --copy-libs
The directory mentioned in the error message (/home/kivy/KivyApp/.buildozer/android/platform/build) is empty, and I believe that the reason this doesn't work is that the python version on the buildozer virtual machine is Python 2.7.13, and when the requirements stated in the buildozer.spec file are kivy, opencv, and python3, it tries to pip install them resulting in an error for the last 2.
The Buildozer.spec file:
https://docs.google.com/document/d/1UAHekPUatAOrdIU_zFRwoPWgQKd-d0L3QsRXOr2Lo4Q/edit?usp=sharing
So, in general, I wanted to fully understand the problem before trying to install a new version of python on the buildozer virtual machine. If my assumption is incorrect, please correct me and if possible, direct me to the correct answer.
Thanks!

It is not a wonder. Python3 and android and Kivy is still in experimental state.
https://kivy.org/doc/stable/guide/packaging-android.html
Better to wait or to use Python2.7

Related

p4a Could not find `android` or `sdkmanager` binaries in Android SDK. Exiting

I spend hours struggling on this issue and I feel dumb as f***. I followed this doc, installed everything I needed until the effective building step:
p4a apk --debug --private $HOME/Documents/Code/Python/app_kivy/identifier/main.py --package=org.example.myapp --name "My application" --version 0.1 --bootstrap=sdl2 --requirements=python2,kivy
[INFO]: Will compile for the following archs: armeabi
[INFO]: Found Android API target in $ANDROIDAPI
[ERROR]: Could not find `android` or `sdkmanager` binaries in Android SDK. Exiting.
Here is the end of my .bashrc
# Adjust the paths!
export ANDROIDSDK="$HOME/Android/Sdk/"
export ANDROIDNDK="$HOME/Apps/android-ndk-r16b/"
export ANDROIDAPI="19" # Minimum API version your application require
export ANDROIDNDKVER="r16b" # Version of the NDK you installed
I tried several paths variants, tried both the full Android Studio and the ‘just the command line tools’ methods of the doc, nothing. NB android and sdkmanager are installed in different folders (resp. tools and tools/bin). I am pretty sure that I am missing something in the .bashrc but what am I missing?
Thanks in advance for any insight
This p4a error message is less specific than it implies. $ANDROIDSDK need not even be a valid path to produce this error. That in mind, you should first check that it has even been exported properly by running the command echo $ANDROIDSDK. If you don't see the expected path printed out, you'll need to run your .bashrc script again the way you normally would.
If you do see the expected path, then the most likely problem is that the contents of $HOME/Android/Sdk/ aren't what p4a was expecting. For that I unfortunately can't offer a suggestion of what might be wrong without knowing what the contents are.

Tool unzip is missing, buildozer, kivy

I am new to kivy, and try to build an app for android using kivy.
When i was creating an apk for the app
buildozer android debug
with log_level=2
it shows:
Tool unzip is missing
Command failed: ./distribute.sh -m "kivy" -d "kivytut"
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'm unable to find any tool called upzip for buidozer(python-for-android) on the internet.
Help.
install unzip using:
sudo apt-get install unzip
moreover following are the tools that must be installed:
git
ant
python2
cython (can be installed via pip)
a Java JDK (e.g. openjdk-7)
zlib (including 32 bit)
libncurses (including 32 bit)
unzip
virtualenv (can be installed via pip)
ccache (optional)
These are several dependencies for python-for-android

Kivy Buildozer - "No module named setuptools" after installing setuptools

I have a Flask server in a Python file. It's really simple:
from flask import Flask
app = Flask(__name__)
#app.route('/')
def hello():
return "Hello World!"
if __name__ == '__main__':
app.run()
I'm using Kivy's Buildozer to build my file. After creating buildozer.spec and specifying requirements = kivy,flask I try to build with buildozer -v android debug which should build the APK.
Instead, it crashes in the middle of building and gives me this error:
File "setup.py", line 4, in
from setuptools import setup
ImportError: No module named setuptools
This setup.py is Buildozer's, not mine.
I uninstalled setuptools completely with sudo apt-get purge python-setuptools, sudo -H pip uninstall setuptools, and I removed the easy_install command from /usr/local/bin (both easy_install and easy_install-2.7). I run sudo easy_install and it says it's not there. Good.
Then I follow instructions from here, and I run wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python. It installs successfully, and I test that easy_install is there by doing sudo easy_install and checking at /usr/local/bin. I also go into the Python shell and type from setuptools import setup and it works. So, setuptools is installed. However, buildozer -v android debug still fails with the same error.
Could someone figure out what's happening? Setuptools is installed; why is Buildozer not finding it?
This is my log, with log_level = 2 in buildozer.spec: Link
You are using the old python-for-android toolchain, which does not support a flask backend. Run buildozer android_new debug instead to use the new toolchain.
Try to figure out which python binary (environment) does the buildozer use. My guess that it uses another one then the one you think, and there setuptools isn't installed.

Command failed: ./distribute.sh -m "kivy" -d

I am trying to follow the instructions on https://kivy.org/docs/guide/packaging-android-vm.html to create kivy android applications. I installed Kivy Buildozer VM and was following instructions on the Readme file. Created the buildozer.spec file using buildozer init command but buildozer android debug is failing with following output
(cd /media/sf_virtual_box/organizer/2nd_vid_tute/step07_padding/.buildozer/android/platform/python-for-android/build/python-install/bin; ln python2.7 python)
ln: failed to create hard link ‘python’ => ‘python2.7’: Operation not permitted
make: *** [bininstall] Error 1
Leaving ARM environment
cp: cannot stat ‘build/lib.*-2.7/_ctypes*.so’: No such file or directory
# Command failed: ./distribute.sh -m "kivy" -d "myapp1"
#
# 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
How can I fix this?
This will occur if the kivy project on the Virtual Machine is in a shared folder with the host machine.
(In my case the host is Windows.)
If this is the case, try copying the kivy project folder to /home/, and make sure this is not shared.
Make sure the permissions are set to 777.

How to compile kivy and python files to apk

i want to convert my python and kivy files into signed and unsigned apk. i work on windows but for compiling using python for android in ubuntu in vm ware. After installing all necessary modules like kivy, python for android and android studio.
when i am compiling it's showing error that sdk not found.
is there any option for generating apk in windows or ubuntu or linux.
i also heard about buildozer and it also works on windows.
please suggest me something on it i'm new to kivy.
thanks
1
I suggest using buildozer instead of p4a - the buildozer uses it internally. It can also automatically download specified android sdk for you.
Install it using pip: sudo pip install buildozer
Once you have it installed, go to your project directory and type:
buildozer init
# edit the buildozer.spec, then
buildozer android_new debug deploy run
Find more info on the github.

Categories

Resources