2011-03-16 15:04:34 +00:00
|
|
|
.. _android:
|
|
|
|
|
|
|
|
Kivy on Android
|
|
|
|
===============
|
2011-02-03 03:07:30 +00:00
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
Requirements for android application
|
|
|
|
------------------------------------
|
2011-02-03 03:07:30 +00:00
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
As soon as you want to do an application for android platform, you must have a
|
|
|
|
file named `main.py` in for root directory of your application, and handling
|
|
|
|
the android platform in the `__name__` test::
|
2011-02-03 03:07:30 +00:00
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
if __name__ in ('__main__', '__android__'):
|
|
|
|
YourApp().run()
|
|
|
|
|
|
|
|
|
|
|
|
Packaging your application into APK
|
|
|
|
-----------------------------------
|
|
|
|
|
|
|
|
To be able to package your Kivy application into an APK, you must have some
|
|
|
|
tools available in your PATH:
|
|
|
|
|
|
|
|
* Java
|
|
|
|
* Python 2.7 (not 2.6.)
|
2011-04-27 10:18:44 +00:00
|
|
|
* Jinja2 (python module)
|
2011-04-22 14:24:47 +00:00
|
|
|
* Apache ant
|
|
|
|
* Android SDK
|
|
|
|
|
|
|
|
You must download the tool named Kivy-XXX-android.zip, available at
|
|
|
|
http://code.google.com/p/kivy/downloads/list, and unzip it.
|
|
|
|
|
|
|
|
Build in debug mode
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Inside the package, you have a tool named build.py. This is the script that will create APK for you::
|
|
|
|
|
|
|
|
./build.py --dir <path to your app>
|
|
|
|
--name "<title>"
|
|
|
|
--package <org.of.your.app>
|
|
|
|
--version <human version>
|
|
|
|
--icon <path to an icon to use>
|
|
|
|
--orientation <landscape|portrait>
|
|
|
|
--permission <android permission like VIBRATE> (multiple allowed)
|
|
|
|
<debug|install|release>
|
|
|
|
|
|
|
|
The last argument stand for:
|
|
|
|
|
|
|
|
- debug: build debug version and save to bin directory
|
|
|
|
- install: same as debug + upload on connected device
|
|
|
|
- release: build release version and save to bin directory
|
|
|
|
|
|
|
|
For example, if we imagine that touchtracer demo of Kivy is in the directory
|
|
|
|
~/kivy/examples/demo/touchtracer, you can do::
|
|
|
|
|
|
|
|
python build.py --dir ~/kivy/examples/demo/touchtracer \
|
|
|
|
--package org.demo.touchtracer \
|
|
|
|
--name "Kivy Touchtracer" --version 1.0.6 debug
|
|
|
|
|
|
|
|
The debug binary will be generated in bin/KivyTouchtracer-1.0.6-debug.apk.
|
|
|
|
|
|
|
|
Then in later time, you can install directly to your android device by doing::
|
|
|
|
|
|
|
|
adb install -r bin/KivyTouchtracer-1.0.6-debug.apk
|
|
|
|
|
|
|
|
Or you can use the `install` method instead of `debug`.
|
|
|
|
|
|
|
|
Release on the market
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Launch the build.py script again, with the `release` command, then, you must
|
|
|
|
sign and zipalign the apk. Read the android documentation at:
|
|
|
|
|
|
|
|
http://developer.android.com/guide/publishing/app-signing.html
|
2011-02-03 03:07:30 +00:00
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
The release binary will be generated in bin/KivyTouchtracer-1.0.6-unsigned.apk
|
|
|
|
(for previous touchtracer example.)
|
|
|
|
|
|
|
|
|
|
|
|
Packaging your application for Kivy Launcher
|
|
|
|
--------------------------------------------
|
2011-02-03 03:07:30 +00:00
|
|
|
|
2011-03-16 16:56:52 +00:00
|
|
|
The Kivy launcher is an application to run any Kivy examples stored on your
|
2011-03-16 15:04:34 +00:00
|
|
|
SD Card from android. See :ref:`androidinstall`.
|
2011-02-03 03:07:30 +00:00
|
|
|
|
|
|
|
Your application must be saved into::
|
|
|
|
|
|
|
|
/sdcard/kivy/<yourapplication>
|
|
|
|
|
|
|
|
Your application directory must contain::
|
|
|
|
|
2011-03-16 16:56:52 +00:00
|
|
|
# Your main application file:
|
|
|
|
main.py
|
|
|
|
# Some infos Kivy requires about your app on android:
|
|
|
|
android.txt
|
2011-02-03 03:07:30 +00:00
|
|
|
|
2011-03-16 16:56:52 +00:00
|
|
|
The file `android.txt` must contain::
|
2011-02-03 03:07:30 +00:00
|
|
|
|
|
|
|
title=<Application Title>
|
|
|
|
author=<Your Name>
|
|
|
|
orientation=<portrait|landscape>
|
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
|
|
|
|
Debugging your application on android platform
|
|
|
|
----------------------------------------------
|
|
|
|
|
|
|
|
Android SDK ship a tool named adb. Connect your device, and run::
|
|
|
|
|
|
|
|
adb logcat
|
|
|
|
|
|
|
|
You'll see all the log, but also your stdout/stderr, Kivy logger.
|
|
|
|
|
|
|
|
|
2011-03-16 16:56:52 +00:00
|
|
|
Status of the Project
|
2011-02-03 03:07:30 +00:00
|
|
|
---------------------
|
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
This project is a derivated work of Pygame Subset for Android, made by Tom
|
|
|
|
Rothamel. His work is available at::
|
|
|
|
|
|
|
|
https://code.launchpad.net/~pgs4a-developer/pgs4a/mainline
|
|
|
|
|
|
|
|
This project code is available at::
|
|
|
|
|
|
|
|
https://code.launchpad.net/~tito-bankiz/pgs4a/kivy
|
|
|
|
|
|
|
|
We made that branch to be able to:
|
2011-02-03 03:07:30 +00:00
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
- integrate Kivy android-support branch in the build
|
|
|
|
- create opengl es 2 surface with stencil buffer
|
|
|
|
- enable multitouch event
|
|
|
|
- custom start.pyx to launch kivy application
|
|
|
|
- default activation of WRITE_EXTERNAL_STORAGE permission
|
2011-02-03 03:07:30 +00:00
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
Currently, Kivy is not fully supported on Android. We are missing:
|
2011-02-03 03:07:30 +00:00
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
- Video providers
|
|
|
|
- Camera providers
|
|
|
|
- Audio (can use RenPySound) providers
|
|
|
|
- Keyboard mapping for main button
|
|
|
|
- Ability to hook app on sleep/wakeup
|
|
|
|
- Ability for an application to have a settings screen
|
2011-02-03 03:07:30 +00:00
|
|
|
|
2011-03-16 16:56:52 +00:00
|
|
|
Tested Devices
|
|
|
|
--------------
|
|
|
|
|
|
|
|
These Android devices have been confirmed working with Kivy. If your
|
|
|
|
device is not on the list, that does not mean that it is not supported.
|
|
|
|
If that is the case, please try running Kivy and if it succeeds let us
|
|
|
|
know so that we can update this list. Note, however, that your device has
|
|
|
|
to support at least OpenGL 2.0 ES.
|
2011-02-10 16:04:26 +00:00
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
Phones
|
|
|
|
~~~~~~
|
|
|
|
|
2011-02-10 16:04:26 +00:00
|
|
|
- Motorola Droid 1
|
|
|
|
- Motorola Droid 2
|
2011-02-23 20:10:11 +00:00
|
|
|
- HTC Desire
|
2011-02-10 16:04:26 +00:00
|
|
|
- HTC Desire Z
|
|
|
|
- Xperia 10 (custom ROM 2.1 + GLES 2.0 support)
|
|
|
|
|
2011-04-22 14:24:47 +00:00
|
|
|
Tablets
|
|
|
|
~~~~~~~
|
|
|
|
|
|
|
|
- Samsung Galaxy Tab
|
|
|
|
- Motorola Xoom
|
|
|
|
|