Starting to Use Kivy : Developing "Letter of Heroes", An Android Alphabet Teaching Aid Application for Kids - Part 1 of 2
Lets turn these fictional superheroes into ... kids teaching aid!
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 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
- Download and install VirtualBox for your Operating System (or in VirtualBox term, it will be known as host Operating System).
- 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.
- Open VirtualBox, create a New Operating System and choose Linux Ubuntu for the type of Operating System.
- Forward to the next steps, and after reaching Hard Drive page, select "Use and existing virtual hard drive file" and choose the extracted
- DONE. Now you can run this newly installed Linux Ubuntu Operating System to build Android APK for your Kivy application.
$ cd ~/code/kivy/examples/demo
$ python touchtracer/main.py
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
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.
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.
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
$ ./distribute.sh -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.
$ ./build.py --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!
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...
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