build android web view app by python (python-for-android)

last modified : 2017-05-29 | published: 2017-05-29 | category:


Installing p4a

sudo pip install git+

Installing Dependencies

sudo apt-get update
sudo apt-get install -y build-essential git zlib1g-dev python2.7 python2.7-dev libncurses5:i386 libstdc++6:i386 zlib1g:i386 openjdk-8-jdk unzip ant ccache
sudo pip install virtualenv 
sudo pip install cython

Installing Android SDK

android-sdk-23 android-ndk-r12b

edit ~/.bashrc,add at end

export ANDROIDSDK="$HOME/android-sdk-23"
export ANDROIDNDK="$HOME/android-ndk-r12b"
export ANDROIDAPI="19"
export ANDROIDNDKVER="r12b"

Flask Demo

create ~/code/myapp/

from flask import Flask
app = Flask(__name__)

def hello_world():
    return 'Hello World!'

if __name__ == '__main__':

project path is ~/code/myapp file with the python script to be run

Build APK

p4a apk --private $HOME/code/myapp --package=org.example.myapp --name "App Name" --version 0.1 --bootstrap=webview --requirements=flask --port=32145 --arch=armeabi-v7a