Starting to Use Kivy : Developing "Letter of Heroes", An Android Alphabet Teaching Aid Application for Kids - Part 1 of 2

Lets turn these heroes into an .. Alphabet Teaching Aid for Kids!

Lets turn these fictional superheroes into ... kids teaching aid! Laughing

As with any boys, my 3 years son is very fond of any fictional Superhero characters : whether it's coming from Marvel or DC universe (or else for that matter). Actually, I highly responsible for this : I intentionally introduce them to it by watching superhero movies every Saturday night. He loves all of them!   

After he already love them, now is the perfect time to use that love, in encouraging him learning how to read. In this article, I am going to guide you on developing a teaching aid for kids in learning alphabet using Kivy. Let see how well Kivy can support us in obtaining our goal!

I have already mentioned Kivy once in my previous article, in which I said, "Write 100% in Python and have it packaged into Windows/Mac/Linux/iOS/Android with full touches capabilities". In developing this teaching aid application, I am going to concentrate the target platform to Android, so my son can play with it in a Galaxy Samsung Tab 2 device (which I intentionally acquired as a testing device for my Android application and at the same time will served as a good teaching device for my kids).  

Preparing Development Environment

Installing Python for Android VirtualBox VM

If you plan to target Android platform using Kivy, don't waste your time : use the provided VM image

If you plan to target Android platform using Kivy, don't waste your time : use the provided VirtualBox image.

As I am going to concentrate my target platform for Android, this shorted down my  development platform into Linux. If you don't have a specific requirement like this, then you don't have to use Linux. You can easily use Windows/OSX for your development machine. The reason why we have to use Linux for Android development is, because the existing Python for Android tool currently support Linux only.

To avoid any development machine configuration obstacles (believe me, I tried), lets just use the existing VirtualBox image provided by Kivy. This means, you will still be able to develop Kivy application either using OSX/Windows, but when you want to prepare its Android APK, then you have to fireup the provided virtual machine.

In case stumbling into VirtualBox is a new thing for you, provided below is the step by step instructions on how you can create a new guest OS from the existing Python for Android VirtualBox image which reside in a single Kivy_Python_for_android.vdi file.

  1. Download and install VirtualBox for your Operating System (or in VirtualBox term, it will be known as host Operating System).
  2. Download and extract the aforementioned VirtualBox Image via Google Drive or Torrent. Using Google Chrome, I failed twice downloading it via Google Drive (got Network Error just when it reached 100%) and finally managed to successfully downloading it via Torrent.
  3. Open VirtualBox, create a New Operating System and choose Linux Ubuntu for the type of Operating System.
  4. Forward to the next steps, and after reaching Hard Drive page, select "Use and existing virtual hard drive file" and choose the extracted  Kivy_Python_for_android.vdi file
  5. DONE. Now you can run this newly installed Linux Ubuntu Operating System to build Android APK for your Kivy application.
To test whether your Kivy installation working as expected, lets run one of the examples already shipped with this VM. Open a Linux terminal/console, and issue the following commands:

$ cd ~/code/kivy/examples/demo
$ python touchtracer/

It will run the infamous touchtracer demo application, seen below.

Touchtracer Kivy demo application

Configuring VirtualBox to Read/Write Host OS Filesystem and USB

I installed VirtualBox in a Windows 7 machine (in a Macmini, through its Bootcamp) and stored my Kivy application code in Windows 7. This means Python for Android tools in guest OS (Ubuntu Linux) must be able to read/write to its Host OS (Windows 7). It must also have read/write access to my Samsung Galaxy Tab 2 connected to Macmini USB port. To achieve these features, first you must install VirtualBox Guest Additions utilities. Simply locate the menu "Install guest additions CD image" from VirtualBox mini bar. It will insert a CD image into guest OS. Ubuntu will automatically prompted to run its Autorun script. Run it and wait for a while. Shutdown your VM.

Install Guest additions utilities

Install Guest additions utilities

With your guest OS shutdown, open its settings page and select Shared Folders. There, you can choose which folder that you would like to be shared to guest OS.

Configure shared folders

Configure shared folders


This only instruct VirtualBox to prepare those folders to be available for guest OS. From inside Linux itself, you have to mount it using the following console command:

$ sudo mount -t vboxsf coding ~/winhome/coding

Of course you have to use your own shared folders name and local directory inside Linux guest OS.

To automatically mount these two folders each time Ubuntu startup, simply edit the file /etc/fstab and add these lines:

coding                                    /home/kivy/winhome/coding               vboxsf
c                                         /home/kivy/winhome/c                    vboxsf

Lastly, to configure Python for Android to be able to install your application into your android device, simply plugged it into your USB port and open guest OS settings page. Headed for USB page and add your USB device from the list.

Configure your USB port to accept Android device

Configure host OS USB port to be read from guest OS


Building Android Application Package

Now, lets test whether we really can build an Android APK file from Python Kivy application and  install it to an Android device attached to the host OS, from within a Linux guest OS (phew, that took sometimes to write!).

Open up a console/terminal, and let prepare first our Python for Android distribution directory.

$ cd ~/android/python-for-android
$ ./ -m "kivy"

Please be patient while the distribution process is finished. Once done, it will create a dist/default directory, which consisted of all required resources to build a Python Kivy application for Android. Lets take our beloved touchtracer  application, prepare its Android APK file and finally install it into attached Android device.

With your android device attached, within your console/terminal, issue these commands.

$ ./ --package com.kivy.touchtracer --name TouchTracer \
    --version 1.0 --dir ~/code/kivy/examples/demo/touchtracer debug installd

Please wait for a moment. And once done, you will have a nicely installed Python Kivy touchtracer  application in your Android application list. Try to run it!

 Touchtracer application running in Android with five touches

Touchtracer application running in Android with five touches


What's Next?

This is the first article talking about building a letter of alphabet teaching aid for kids using Kivy. In this article I dedicate a certain amount of time trying elaborately to explain how to use the provided Kivy Linux Ubuntu Virtual Box image to build your Kivy application for Android. If not hardly trying to configure those Python for Anroid in my current Linux box myself, this article will hit last week. But there are so many obstacle that I encountered, and I simply gave up... Laughing 

Our next article will talk about developing Letter of Heroes, a Kivy application aimed to teach kids learning alphabet in a much more fun way... Hopefully Tongue out


Leave comments

  • What a superb guide, many thanks. A couple of things:

    When you autorun the guest additions CD image, you're going to be prompted for a password - it is 'kivy123'.

    If you get "No such file or directory" error after the mount command, you have to actually mkdir the directory first. This might be obvious to Linux people but wasn't to me!

    Before issuing the "./" command, you have to cd dist/default

    Great tutorial, much appreciated. Saved me hours.

    • Chris Rae
  • @Kayla : Well, that is unfortunate. But with my pass experience in mass-porting mobile game into different phone type, that case often occur. I think you should write to kivy user group,, and state what your phone model is.

    I hope a solution is there for you!

    • eko
  • Thank you for the amazing write up : ]

    I see the kivy touchtracer app in my applications on my phone, but when I run it, it says "Loading...." and then closes. Do you know why this might be happening?

    • Kayla
  • Hi @Kayla,

    That it's beneficial for you!

    * I still have one demo to be published actually


    • eko
  • Thank you - SO helpful!!

    • Kayla
  • Haha, yep. You're right.
    But as long as we watched, we only found Wonder Woman here.
    Hm, let me think.. there is Supergirl, Powergirl, Black Widow (of course), ... not much!

    Thanks for the input.

    • eko
  • Don't forget to include some female or POC heroes in your program! It's especially important for a young son to know that heroes aren't always male and white. There's plenty to choose from fortunately!

    • jf
  • Well, I guess you're not using the pre-configured VirtualBox VM, right?
    In my effort to trying to do it myself, I believe that using the same NDK version + Android API version will solve the problem.

    Maybe this SO page can give you a hint :

    As for me, I am not sure what cause the error though :)

    Maybe you can ask Ben Rousch directly. :)

    Good luck!

    • eko
  • command
    $ ./ -m "kivy"
    "Recipe kivi does not exist"
    Any idea what it means?

    • name
  • Hi Ben!
    Thanks for your prompt comment :)
    I truly got the obstacles when tried to configure Py4a in my current linux box. Upon giving up, I simply use the provided VM there. What a timesaver...

    The local cloud service will be great. I have tried, but the waiting list is not intriguing. One will not have the patient if what they one is to test the APK result.

    By the way, do you have any speed comparison in Kivy application? It will be a great marketing aid for Kivy ;)


    • eko
  • Thanks for this great write-up! All of the work you put into trying to get py4a working and configuring the virtual machine reinforces my opinion that we need an easier way to build APKs with Kivy. Thanks for sticking with it! One of my long-term plans is a cloud service (hosted and local) where you can submit your code and it generates the APK for you.

    • Ben Rousch

Copyright(c) 2017 -
By using this website, you signify your acceptance of Terms and Conditions and Privacy Policy
All rights reserved