'''NOTE:''' python-for-android just has a major update at the beginning of Oct, 2015. For compatability purpose, our current development is still based on the old version (the "old_toolchain" branch on the git repo). 

To set up the development environment for MobileInsight2, please refer to the following instructions.

1. Download the src code of the python-for-android environment, an open-source framework which allows using Python to develop Android apps. The project's git repository locates at: https://github.com/kivy/python-for-android/tree/old_toolchain

2. Follow the official documentations to install python-for-android. However, since the doc of this project is not well-written, we need some extra works to set it up.

(1) Download the Android NDK and SDK versions that are specified on the git repo's [https://github.com/kivy/python-for-android/blob/old_toolchain/README.rst README] page, which is NDK r8c and SDK 14. Also, remember to set up your environment variables.

The Android NDK r8c can be downloaded here:
  
  http://dl.google.com/android/ndk/android-ndk-r8c-darwin-x86.tar.bz2 (for OS X)
  http://dl.google.com/android/ndk/android-ndk-r8c-linux-x86.tar.bz2 (for Linux)

The Android SDK 14 can be configured by Android update service.

(2) Install the necessary prerequisites using apt-get and python-pip. See http://python-for-android.readthedocs.org/en/latest/old_toolchain/toolchain/#prerequisites for details.

(3) Note that a known Cython issue (https://github.com/kivy/buildozer/issues/150) will cause errors in the coming steps. Use "pip install cython==0.20" to install the version we use.

3. Read step 4~8 on the git repo's README page to compile a "distribution", and to build an example app using the distribution.


'''NOTE from Zengwen:'''

I used `ANDROID NDK-r9d and SDK-19' and Cython version 0.20.1post0, and successfully built `dist/default' for python-for-android and the example project `HelloWorld' from the p4aDoc (http://python-for-android.readthedocs.org/en/latest/old_toolchain/examples/#hello-world).

  # added for python-for-android project
  export ANDROIDSDK="/path/to/android-sdk-linux"
  export ANDROIDNDK="/path/to/android-ndk-r9d"
  export ANDROIDNDKVER=r9d
  export ANDROIDAPI=19