Mobile Development 11 min read

How to Develop and Package a Python App with Kivy and Buildozer

This tutorial explains how to set up the Kivy framework on macOS and Linux, write a simple Python hello‑world app, test the installation, install and configure Buildozer, and use it to package the app into an Android APK while addressing common build issues.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
How to Develop and Package a Python App with Kivy and Buildozer

The article introduces Kivy, an open‑source cross‑platform Python framework for building GUI applications, and explains why Python is not ideal for production mobile apps but can be used for learning or hobby projects.

Preparation

Kivy must be installed as a Python module; it supports Linux, macOS, Windows, Android, and iOS.

Setting up the Kivy development environment

Installation steps for macOS:

brew install pkg-config sdl2 sdl2_image sdl2_ttf sdl2_mixer gstreamer
pip install cython==0.25
pip install kivy

If the above fails, install from source:

git clone https://github.com/kivy/kivy
python setup.py install

Installation steps for CentOS 7 include installing many 32‑bit libraries, then:

yum install -y make mercurial automake gcc gcc-c++ ... python-pip java-devel
pip install Cython==0.20
pip install kivy

After installation, test with:

$ python
>>> import kivy

Successful import indicates a correct setup.

Creating the first Kivy app

Create main.py :

#! -*- coding:utf-8 -*-
from kivy.app import App
class HelloApp(App):
    pass
if __name__ == '__main__':
    HelloApp().run()

Create hello.kv :

Label:
    text: 'Hello, World! I am nMask'

Run the app with python main.py and verify the window appears.

Installing Buildozer

Buildozer automates packaging Kivy apps for Android and iOS.

pip install buildozer

Packaging the app into an APK

In the project directory:

buildozer init

Edit buildozer.spec as needed, then run:

buildozer android debug deploy run

The first run downloads Android SDK/NDK and other dependencies. After a successful build, an .apk file appears in the bin folder and can be installed on a device.

Common build issues and fixes

Missing 32‑bit libraries on CentOS can be resolved by installing the extensive list of .i686 packages shown in the article.

Cython version mismatches are fixed by reinstalling a specific version, e.g., pip install cython==0.25 .

File‑not‑found errors during the final copy step can be solved by patching /usr/local/lib/python2.7/dist-packages/buildozer/targets/android.py to use the latest build‑tools version (see the provided code snippet).

Buildozer virtual machine

Kivy provides a pre‑configured Buildozer VM image that contains all dependencies, useful for users who cannot resolve library issues on their own machines.

Download link: kivy-buildozer-vm-2.0.zip

Conclusion

The guide demonstrates a minimal Kivy app workflow, from environment setup to APK generation, and offers troubleshooting tips for common pitfalls.

mobile developmentcross‑platformPythonAPKTutorialKivyBuildozer
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.