Deploying Your Kivy/Python App to Android with Buildozer

preview_player
Показать описание
Follow along with me as I deploy a simple Hello World Python/Kivy application to an Android phone. I used a Windows machine running an Ubuntu 18.04 image in VirtualBox since buildozer doesn't run directly on Windows.👇 LINKS AND INFO! 👇

EVERY COMMAND FROM THE VIDEO:

Step 3) Make sure your phone is in Developer mode by going to Settings -- About Phone -- Software -- tap on 'Build Number' 7 times quickly. Now go to Settings -- Developer Options and enable Stay Awake and USB Debugging.

Step 4) Connect your phone to your computer and make sure to Always Allow USB Debugging when your phone connects.

Step 5) Set up a new virtual machine in Virtualbox using the image from step 2. I allocated 2048 MB of memory and 20 GB of disk space.

Step 6) Install Ubuntu on the virtual machine

Step 7) Open the Terminal in your virtual machine and run the following commands:

Sudo apt install git

cd buildozer

sudo apt-get install python3.6

sudo apt-get install -y python3-setuptools

cd ..

cd KivyHelloWorld

buildozer init

sudo apt update

sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev

pip3 install --user --upgrade cython virtualenv

Sudo apt-get install cython

buildozer android debug deploy run

If you run into any errors, watch the video ;)

--------------------------------------------------------------------------------------------------------

Any and all donations are super appreciated! ❤️

The creators of Kivy have been developing the framework for near a decade without funding. They recently set up a fundraising campaign in an attempt to fund one (to start) core developer of the framework. If you are so inclined, join me in contributing a small donation to help fund this wonderful project. I'm sure they really appreciate the support! Use the link below to check out their donation page. ❤️

Thanks for watching!

- Erik

Follow me on Github!

This video uses the following music:

Рекомендации по теме
Комментарии
Автор

What a sick intro.


I wrote all of the steps down in the description of today's video, so you can copy/paste commands into the command line if you want! Good luck getting your apps on Android everyone!

erik-sandberg
Автор

I never comment on anything but this helped me a ton (especially after trying to figure it out for over a week about 10 hours a day). If you are using a python module that requires you to utilize the internet (like say, paho-mqtt), make sure you change the permissions in your buildozer spec file (i think it's line 91) and allow the permissions for INTERNET. (i.e. delete the #). Before then my app would display the splash page and then crash. Literally, no video or article or stack overflow says to do this, hopefully this helps someone to not spend over 80 hours figuring it out ;)

johnabual-nile
Автор

This is the cleanest explanation ever. Omg I wasted so much time while I could just simply watch this video.

Dtomper
Автор

Excelent video. For Xiamoi users, you need to toggle "install via USB" too, under "USB debugging" for the deploy to work

mateusrodolfo
Автор

ERROR: Could not find a version that satisfies the requirement Cython (from versions: none)
ERROR: No matching distribution found for Cython
What should i do for this error ?
I am using kali linux

Edit: sudo apt-get install libssl-dev
Fixes the problem

logeshwaranr
Автор

Great job. Could you please create a tutorial that enables Google play inapp purchase subscriptions using python+kivy+buildozer please?

chavarinbonbyn
Автор

I love you. It took me THREE days to get my app run on my phone having several errors I could not find anywhere. The worst thing is that I only discovered your video last night. This helped me so much. Still had to fix few errors which you did not have in the video (still ateup a lot of time) but now I have my Thank you so much! WIthout your video I probably would not be near to ready by now!

timmaassen
Автор

Thank you thank you thank you so much!!! I've been struggling with this for a long time.

michaelkk
Автор

very well done. I ended up compiling apk for x64 devices and its only 12mb in size. For anyone having issues with gradle error be sure to use the same jdk-8 as mentioned in the video. Don't use the latest one!

neopiru
Автор

Fantastic work here, just wanted to add that the developer must make sure that cython is installed in the system and not only virtual env as it will throw up some error messages,

amlo
Автор

thank you so much! i've never had an easier time following one of these technical tutorials. only one major problem that the comment section had a fix for me. very useful tutorial (problem was an error at the end of the last command, solved by Joona Syrjämäki)

justinknew
Автор

keep this on brother. Have been learning from most of your tutorials! Thank you

azimmirzoev
Автор

Great Vid! Building for Android is definitely a pain point for most people, myself included. Would love to see more examples of including files and other modules in the build over spec . Also, have you ever tried kivymd and other modules in Kivy launcher ?

thewilltejeda
Автор

Wow it worked! Thanks Erik :) liked, subscribed and recommended!

robh
Автор

Awesome man.. You are a code saver.. I thought there was no way i am going to make apk out of my kivy file bcz of complicity but you saved me....

suyashvashishtha
Автор

I'm so happy for this, but please i need a tutorial for deploying kivymd, i built several Apps with only kivy, and whenever i tried for kivymd it crashes on the Android device. Please help

shadeeztv
Автор

Bro I am getting error which says could not find a version to satisfy the requirement python (from versions: none)....

akmaljahan
Автор

It creates and runs the apk but after that my app immediately crashes. Any solutions about that😫

fizz
Автор

You won't believe how much it helped me. Thank you so much!

hikkifans
Автор

I have used VMWare workstation 15, Ubuntu 18.04, python 3.6
pip3 version 9.0.1

I have followed the your instruction and try to deploy but it showing the following error

Please help... Thanks in advanced...

*** PYTHON PACKAGE / PROJECT INSTALL STAGE ***
[INFO]: The requirements (certifi) don't have recipes, attempting to install them with pip
[INFO]: If this fails, it may mean that the module has compiled components and needs a recipe.
[INFO]: -> directory context
[INFO]: -> running python3 -m venv venv
[INFO]: Upgrade pip to latest version
[INFO]: -> running bash -c source venv/bin/activate && pip install -U pip
[INFO]: Install Cython in case one of the modules needs it to build
[INFO]: -> running bash -c venv/bin/pip install Cython
Exception in thread background thread for pid 89272:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/am-ubuntu/.local/lib/python3.6/site-packages/sh.py", line 1662, in wrap
fn(*args, **kwargs)
File "/home/am-ubuntu/.local/lib/python3.6/site-packages/sh.py", line 2606, in background_thread
handle_exit_code(exit_code)
File "/home/am-ubuntu/.local/lib/python3.6/site-packages/sh.py", line 2304, in fn
return
File "/home/am-ubuntu/.local/lib/python3.6/site-packages/sh.py", line 877, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /bin/bash -c 'venv/bin/pip install Cython'
STDOUT:
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting Cython
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/cython/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/cython/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/cython/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/cython/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/cython/
ERROR: Could not find a version that satisfies the requirement Cython (from versions: none)
ERROR: No matching distribution found for Cython
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

STDERR:

Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/am-ubuntu/kiv/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1231, in <module>
main()
File "/home/am-ubuntu/kiv/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
ToolchainCL()
File "/home/am-ubuntu/kiv/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 688, in __init__
getattr(self, command)(args)
File "/home/am-ubuntu/kiv/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 154, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/home/am-ubuntu/kiv/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 208, in build_dist_from_args
args, "ignore_setup_py", False
File "/home/am-ubuntu/kiv/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 598, in build_recipes

File "/home/am-ubuntu/kiv/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 778, in run_pymodules_install
), _env=copy.copy(base_env))
File "/home/am-ubuntu/kiv/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 167, in shprint
for line in output:
File "/home/am-ubuntu/.local/lib/python3.6/site-packages/sh.py", line 925, in next
self.wait()
File "/home/am-ubuntu/.local/lib/python3.6/site-packages/sh.py", line 849, in wait

File "/home/am-ubuntu/.local/lib/python3.6/site-packages/sh.py", line 877, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /bin/bash -c 'venv/bin/pip install Cython'
STDOUT:
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting Cython
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/cython/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/cython/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/cython/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/cython/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/cython/
ERROR: Could not find a version that satisfies the requirement Cython (from versions: none)
ERROR: No matching distribution found for Cython
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

mamartyacse