Kivy on Android

Kivy is a Python library that supports multi-touch devices. Documentation and installation guide can be found at the Kivy site:

Kivy can be run on Android phones using the Kivy Launcher (from the Android store) or an APK can be build using Python for Android (see

Using Python for Android

Here is a simple "Hello World" example of using Kivy (from the documentation). The program should be called
from import App
from kivy.uix.button import Button

class TestApp(App):
    def build(self):
        return Button(text='Hello World')

if __name__ in ('__main__', '__android__'):
By writing it this way the program can be tested on a desktop before building for an Android.

To test on an Android phone first connect the Android to your machine via USB. Make sure "USB debugging connected" is enabled and "USB connected" is disabled. To enable debugging go to Settings:Application:Development.

Assuming Python4Android is the path to the Python for Android installation and the current directory is called myapp then the following script will build a debug APK and install it on the phone.

cd $Python4Android/dist/default
rm bin/myapp*
./ --package org.test.myapp --name myapp --version 1.0  --dir $currdir debug
adb install -r bin/myapp-1.0-debug.apk
The APK is built in $Python4Android/dist/default/bin and it appears to be necessary to remove the previous build in order to build a new version.

The default orientation is landscape but it can be changed by adding --orientation portrait to the build.

The icon that appears on the phone for your app can be set with --icon $currdir/my_icon.png. Note that the icon must be a .png image.

Kivy has a config file in $HOME/.kivy. So, for example, the screen height and width can be changed to be the same as the Android device.

For debugging it is useful to run adb logcat on your desktop.

Making a Release

In order to make a release you need to sign the app. See for information about signing.

Once you have generated a keystore you can sign the app as follows (from inside the bin directory).

/ --package org.test.myapp --name myapp --version 1.0  --dir $currdir release
jarsigner -verbose -keystore your_key_store myapp-1.0-release-unsigned.apk your_key
jarsigner -verify myapp-1.0-release-unsigned.apk
zipalign -v 4  myapp-1.0-release-unsigned.apk myapp.apk
adb install -r myapp.apk
The first commands builds a release version. The second commands signs the app. The third command verifies the signing. The fourth command aligns bytes in the apps files. The last command installs the app.