Deploying your Python application to Android


Shyamnath Premnadh

Hi, there ๐Ÿ‘‹


Shyamnath Premnadh aka Shyam
Qt for Python
Senior Software Engineer @ TQtc

Why is Android an important platform ?๐Ÿฆพ

Is Python a good alternative for Java/Kotlin for Android development? ๐Ÿค”

Currently, NO

Python ๐Ÿšซ Android

  1. No official support for Android in CPython
  2. No native support for Python with Android SDK
  3. The app should bundle the Python binaries

Python โค๏ธ Android

  1. No official support for Android in CPython -
    PEP 738: Adding Android as a supported platform - Malcolmn Smith
  2. No native support for Python with Android SDK
  3. The app should bundle the Python binaries

GUI frameworks with Android support

  1. Kivy
  2. Flet
  3. PySide6
  4. PyQt6
  5. Toga

GUI frameworks with Android support

  1. Kivy
  2. Flet
  3. PySide6
  4. PyQt6
  5. Toga

Contact Manager Application๐Ÿ“ฑ

Flet

  • Since 2023
  • Server-Driven UI framework based on Flutter
  • Minimal API - Fully in Python
  • Deploying as a web app on the browser or a progressive web app (PWA)

Contact Manager Application - Flet

Pros and Cons - Flet

Pros
  • More modern UI
  • Easy to get started with
  • Fully in Python
  • Minimal API, but hightly customizable
  • Cross-platform + WebAssembly
  • Active and responsive community
Cons
  • Still very new
  • Limited resources online
  • No visual designer
  • No hardware access
  • Not as mature as PySide6 and Kivy
  • No localization

Kivy

  • Since 2012
  • Two ways to create GUI
    • Python code
    • Kv language
  • More suited for games than traditional applications
  • KivyMD for Material Design

Contact Manager Application - Kivy

Pros and Cons - Kivy

Pros
  • Visual Designer - KivyMDBuilder
  • kv language is easy to learn
  • Both PySide6 and Flet uses `buildozer`
  • More modules than Flet
  • Active community
Cons
  • Need to learn a new language
  • Not as modern as Flet even with KivyMD
  • Not as mature as Qt
  • Not ideal for Desktop platforms
  • Limited resources as compared to PySide6
  • Incomplete API reference
  • Confusing Widget names. eg. Accordion

PySide6

  • Official bindings for the Qt framework (since 1995 ๐Ÿ˜ฎ)
  • Two ways to create GUIs
    • Qt Widgets - Python and C++
    • Qt Quick (Material Design) - QML and Python/C++
  • Visual Designers
    • Qt Widgets - Qt Designer
    • Qt Quick - Qt Design Studio

Contact Manager Application - PySide

Pros and Cons - PySide6

Pros
  • More features and modules than Kivy and Flet
  • Lot of resources
  • Big and active community
  • Easy switch to C++ - high performance
  • Lot of tools eg: Qt Designer, Qt Design Studio etc
Cons
  • Need to learn a new language
  • Steep learning curve
  • Needs to manually create Android wheels
  • No iOS and WebAssembly support
  • Needs a Unix host system

Python Packages Support ๐Ÿ“ฆ

Pure Python Packages - Platform Independent

Python Packages Support ๐Ÿ“ฆ

Pure Python Packages - Platform Independent

What about Native Python Packages?

Python Packages Support ๐Ÿ“ฆ

What about Native Python Packages?

Other Concerns

Flet Kivy PySide6
Python Version 3.11 3.11 3.11
Android NDK Version r23b r25b r26b
Licenses Apache 2.0 MIT LGPLv3/GPLv3 and Commercial
App Size 43 mB 20.5 mB 80 mB

Conclusion ๐Ÿ

Deploying your Python application to Android


Shyamnath Premnadh