[Tutorial] Android development with Python and Kivy - Introduction
In this post I’ll show you how to start with mobile development using Python and Kivy. You will see how to download and configure Kivy, and we will create a Hello World to test it. And finally, we will build our application to an APK, and install it on Android.
I - Installation
Kivy for Android Virtual Machine
If you are going to develop for Android, you must to be using Linux and a lot of dependence are necessary. So it’s not recommend to install everything, it can be hard and may not work perfectly.
To turn our development easier, Kivy provide us a Virtual Machine ready for use!! Yep, you just need to download it and use. Download it from here: http://kivy.org/#download
Scroll to the end of screen, and you will see the download link.
Each platform has a different installation process, so I recommend you to download and install the virtual machine to avoid problems. You can run the VM(based on Ubuntu 32 bits) using Oracle Virtual Box.
Start your VM and let’s create our first project!!
II - Creating our first project
From now, we will create a simple project to test if everything is fine. You can run this source in your computer. After we finish it, we can build for Android.
This code will create a simple window, and a button with the text “Hello World”.
III - Build Python for Android
Now, let’s build our hello world to Android. (The main file of you project must be named as main.py)
To create an Android project with Python and Kivy, open you terminal and run:
The command above will download the necessary tools to start the development. Now, you need to build the modules that you will use in your project. In that case, we are using only Kivy. So, run:
It will download and configure everything that you need.
Now, go to the dist/default folder and run:
For example, in my case, I will run:
This command will build the Apk. The apk will be created at bin folder. Get it and install in your device.
App running on my device:
That’s it!! Now, you are able to develop using Python + Kivy for Android. This blog has more tutorials about it, take a look :)
Thanks for reading, if you need something, just comment here!!