So I just finished the course, Mobile App Development With Kivy & Python – From scratch. I was good and covered alot, but it missed out on the method for making an android packet….I was hoping it was not. In section 54 it said ” Building an android ABK”, but just a link. So I have to ride that journey myself.

So I am going to create a simple book-app, the app will explained in depth later. But short about the app, it will have some buttons, label’s and on_press actions and the layout stored in the .kv file. The label will show text when the buttons are press and a quit button. I might add a button click that opens the browser with a given url. The guide for kivy apps is found here:

After reading several pages, links etc, I found out about python-for-android

python-for-android is a packaging tool for Python apps on Android. You can create your own Python distribution including the modules and dependencies you want, and bundle it in an APK along with your own code.

Features include:

So I will give this a try and document the process.

So 2 hours later, hm…my android packaging is done!

In this order:

sudo dpkg –add-architecture i386

sudo apt-get install build-essential ccache libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386

pip3 install buildozer

cd into app
buildozer init (open, close VSC)

buildozer android debug

Installing/updating SDK platform tools if necessary

change android.sdk, buildozer.spec= 22 (was 20)

Buildozer stuck on “Installing/updating SDK platform tools if necessary”

Press “y” then enter to continue, the license acceptance system is silently waiting for your input

buildozer android debu

log_level = 2 from 1
/home/espen/project/learnkivy/learn/app/.buildozer/android/platform/build/build/other_builds/libffi/armeabi-v7a__ndk_target_21/libffi/ 2: exec: autoreconf: not found

sudo apt-get install automake
sudo apt-get install autoconf
sudo apt-get install libltdl-dev

cd into project
buildozer android debug, Be patient, takes long time

After the command got executed, the APK file will be found at this location under project directory /simpleapp/.buildozer/android/platform/build/dists/simpleapp/bin. The APK file could be transferred to an Android device to run it

And it does but is just launches for 3 seconds and then it is gone, hm

so I did:
buildozer -v android clean
after deleting .buildozer folder from your /home/ and then try
buildozer -v android debug
Also set the log level as 2 in buildozer.spec and if you are using any python library add that in buildozer.spec requirement section with comma after kivy.

buildozer android deploy run logcat (log level as 2 in buildozer.spec) gives “Couldn’t load memtrack module, failed to get memory consumption info: -1” after adb to my samsung phone

Lets try with python 2, it might be that buildozer does not work yet with 3.6, it seems that it has come to 3.5

So now I have ran:

sudo apt install python

sudo apt install python-pip

pip install virtualenv

Lets make a v2 env and install kivy and move the main.kv, to that project and run it

mkdir project2, cd project2

mkdir projectkivy, cd projectkivy

virtualenv -p python kivyenv, source kivyenv/bin/activate

python -V gives Python 2.7.5+

Now we install kivy, move the files and run the app.

pip install kivy gives a fatal error: GL/gl.h No such file

sudo apt-get install libgl1-mesa-dev


Successfully built kivy
Installing collected packages: kivy
Successfully installed kivy-1.11.1

Oh well, Python 2 Kivy support has been deprecated. The Kivy release after 1.11.0 will not support Python 2 anymore

Back tp p3 and the buildozer android deploy run logcat (log level as 2 in buildozer.spec) gives “Couldn’t load memtrack module”

buildozer android deploy is success

buildozer android debug deploy run, says that device is is found, stream install sucess, application started:

Ok, lets debug some more to a txt file and have to look into the java also

buildozer -v android debug deploy run logcat > output.txt

Ok, we got something else:

08-13 15:35:09.101 30388 30514 I python : File “/home/espen/project/learnkivy/learn/app/.buildozer/android/platform/build/build/python-installs/followelo/kivy/”, line 139, in require
08-13 15:35:09.102 30388 30514 I python : Exception: The version of Kivy installed on this system is too old. (You have 1.11.0, but the application requires 1.11.1)
08-13 15:35:09.102 30388 30514 I python : Python for android ended.


Successfully uninstalled Kivy-1.11.1
(kivyenv) espen@espen-UN65U:~/project/learnkivy/learn/app$

pip3 install kivy==1.11.0

Installing collected packages: kivy
Successfully installed kivy-1.11.0

Ok, lets run the app, same error

Right, the main.kv had:

#:kivy 1.11.1, now that is changed to #:kivy 1.11.0. The app starts now as before, lets do buildozer

buildozer -v android debug, is success, ok then

buildozer -v android debug deploy run logcat > output.txt

Some erros, but the app is deployed to the phone, yeas!!!!

Nice, ok lets get rid of the error and change the layout abit and preform the same steps:

buildozer -v android debug

buildozer -v android debug deploy run logcat > output.txt

And then the layout is better:

Short summary:

Install Buildozer with pip, if something is missing install it as well, use the same kivy version, enable adb for your phone to test, enable developer options on your phone (7 clicks on settings->about->), access the dev options for settings with page down (finger on phone) and click the wheel upper right corner. (Developer options in the buttom)

The app now, with an actionview (that I need to fix) and the ScrollView for the text label:


Ok, so I ran:

espen@espen-UN65U:~/project/learnkivy/learn/app$ buildozer -v android debug


The I moved the app from bin to the phone:

And installed the apk file (install anyway) and it works!


Fix v 1.2 app

Upload apk debug file for download

make release file