At this year's EuroPython conference in Florence, Italy, I've been giving a half-day training about Python application development on Android. The training was 240 minutes long and took place on Tuesday July 3rd 2012 at 09:00.
Photo credit: Stefan Kögl
The goal of this training is to show you how to start developing full Android applications using only Python. Different technologies will be demonstrated, including PySide-based QML GUIs using the Necessitas Qt port and the Py4A/SL4A-based approach, which can be combined with Android’s WebKit and re-use Python web frameworks.
While Android already has a good SDK out of the box, being able to use Python instead of Java is a big advantage for some developers - it allows for quicker turnaround times, and reuse of Python libraries. Python on Android uses a native CPython build, so its performance and compatibility is very good. Combined with PySide (which uses a native Qt build) and Qt’s support for OpenGL ES acceleration, you can create fluent UIs even with Python.
The resulting PySide-based applications run on Android, but also at least on Mac OS X, Windows, Linux and Maemo and MeeGo - basically all platforms on which Qt is available. The SL4A/Py4A-based applications will run on Android only, but will be able to utilize Android-specific APIs. Both approaches can also be combined.
To get started, you have to download some packages to your host computer, so you can develop and deploy your Python packages to your Android device:
python android.py installsdk
hg clone https://code.google.com/p/python-for-android/
Unfortunately, due to technical problems, the first part of the video is not available online. The second part can be found here:
Developing Android apps completely in Python part 2 (YouTube)
Don't forget to install the "Android Platform Tools"
Then, to install via adb:
adb install Downloads/sl4a_r5.apk adb install Downloads/PythonForAndroid_r5.apk
See the instructions in the Qt Project Wiki: PySide Binaries for Mac OS X
hg clone https://code.google.com/p/android-python27/
Look into README, copy the environment variable setting + fix paths:
source environment.sh bash bootstrap.sh bash build.sh cp Python/build/lib.linux-i686-2.7/_ctypes.so /path/to/pgs4a/private/ cp -rpv Python/Lib/ctypes ~/src/pgs4a-0.9.4/private/lib/ cd /path/to/pgs4a/ rm -rf private/lib/ctypes/test
cd /data/data/com.googlecode.pythonforandroid/files/python/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/data/com.googlecode.pythonforandroid/files/python/lib
python android.py configure mygame(will write a file
python android.py build mygame release install
http://code.google.com/p/python-for-android/wiki/BuildingPython export ANDROID_NDK=~/pkg/android-ndk-r8/ export PATH=$PATH:$ANDROID_NDK:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/