wiki:THPEuroPython2012TalkNotes

Version 7 (modified by Martin Kolman, 11 years ago) (diff)

--

Notes from THP's EuroPython 2012 Talk]

back to the main Android porting page

These notes were compiled based on the Youtube video of THP's talk from EuroPython 2012 called Developing Android Apps completely in Python.

My notes are prefixed with MartinK: and written in italic.

PySide @ Android

Intro

Based on 3 projects:

  • Python4Android - takes care of the Python interpreter
  • Necessitas - provides Qt libraries for Android
  • PySide - provides Python bindings for Qt

It should be possible to also use PyQt in place of PySide but THP was used to PySide so he used that.

MartiK: As PySide currently (January 2013) doesn't support Qt 5 at all but PyQt does, using PyQt might be needed for using Qt 5 on Android devices.

First build Python4Android for you host system - it is used for compiling PySide (you have to cross-compile PySide for Android).

Then there is a small C++ project called !PySide Launcher - it invokes the Python interpreter from a C++ application. Using it you can use the Necessitas IDE and deploy directly to the device.

The PySide launcher initializes the interpreter, passes it the command-line arguments and runs the main.py file from a folder on the Android sdcard folder.

The result looks from outside like a C++ application, but what it really does is that it calls the Python interpreter, the Python interpreter then calls PySide and PySide calls the Qt APIs so you can have a Qt application.

Necessitas SDK

The Necessitas SDK can be downloaded from here and takes up about 3.5 GB. It contains Android NDK, Android SDK, Qt Creator, Qt compiled for desktop, Qt compiled for Android - basically all in one package.

Creating a project in Qt Creator

Launch the Necessitas QtCreator?, click on create project and select Qt Quick Application. Then name the project and select workspace directory for it.

then on the Qt Quick Application Type tab select Built-in elements only. MartinK:Note to self - check if selecting Qt Quick Components for Meego/Harmattan? on this screen actually does something.