Build An Android App by Python

1 minute read

Published:

Python is everywhere in an engineer’s routine work. You may use it to crawl and scrap web info, build up your machine learning models, or automate a firmware updating process for IoT devices, etc. This post will show you the steps to build an Android App by Python.

Android Settings

Turn on developer mode for your Android device

  • Settings -> About phone
  • Tap the build number for seven times

Turn on USB debugging

  • Settings -> Developer options -> Debugging -> USB debugging

Allow data saving when plugging your device to a computer

  • allow

Computer Terminal

Install Git, Python, Cython, Buildozer

sudo apt install git

git clone https://github.com/kivy/buildozer.git

cd buildozer

sudo apt-get install python3.6

sudo apt-get install -y python3-setuptools

sudo python3 setup.py install 

cd ..

Write your own app script using Python or clone an App repo from github

git clone <some code repo for Android App> # OR write your own 

cd <code repo>

Initialize using buildozer

buildozer init

sudo apt update

sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev

pip3 install --user --upgrade cython virtualenv

sudo apt-get install cython

Modify buildozer.spec

title = test
name = test.org
requirements = plyer,sqlite3,kivy,kivy_garden.graph,python3 (# Modify buildozer.spec)

Compile and build .apk using Buildozer

conda install kivy -c conda-forge

pip install kivy-garden

garden install graph

garden install --app graph

buildozer android debug deploy run