Python has long gone beyond server-side scripts and data analysis - today full-fledged mobile applications for Androidare written in it. But how does it work if officially Android SDK only supports Java/Kotlin i C++? The answer lies in specialized frameworks that translate Python code into native APK files or integrate with Android NDK. This article will cover all the nuances: from choosing a tool to optimizing performance and bypassing key limitations.

We will look at three main approaches: Kivy (for cross-platform UI applications), BeeWare (with a native Python interface) and Chaquopy (Python integration into Java/Kotlin projects). We will pay special attention Critical performance issues when working with graphics and multi-threading, which often become the reason for abandoning Python in favor of native development. You will learn how to get around these limitations and when Python is really justified, and when it is better to immediately choose Kotlin.

Why Python for Android: pros and pitfalls

The main advantage of Python is speed of development. Python code is 3-5 times shorter than its equivalent by Java, and the abundance of libraries (from numpy to requests) allows you to quickly implement complex logic. This is ideal for:

  • ๐Ÿ“Š Prototypes and MVP (Minimum Viable Product) - when you need to show an investor a working product in a week.
  • ๐Ÿ”ฌ Scientific/engineering applicationswhere integration with matplotlib, pandas or TensorFlow Lite.
  • ๐Ÿค– Automation on the device (for example, bots for Telegram or parsing data from sensors).
  • ๐ŸŽ“ Educational projects โ€”Python is easier to learn than Kotlin, and the result can be immediately seen on a smartphone.

However, there is a downside. Python applications on Android:

  • ๐Ÿข Slower than native ones 2-10 times (depending on the framework and task). Critical for games or applications with intensive graphics.
  • ๐Ÿ“ฆ Weigh more - even a simple application on Kivy will take 15-20 MB versus 2-3 MB on Kotlin.
  • ๐Ÿ”‹ Consume more battery due to the additional layer of code interpretation.
  • ๐Ÿ› ๏ธ Require manual configuration to work with native APIs (camera, GPS, Bluetooth).
โš ๏ธ Attention: If your application requires high performance (for example, 3D games or real-time video processing), Python is not suitable. Consider Unity (C#) or native development in Kotlin/C++.
๐Ÿ“Š What do you want to use Python for on Android?
Application prototype
Science/engineering software
Automation tasks
Game
Other

Top 3 frameworks for Python on Android: comparison 2026

The choice of framework determines not only the syntax, but also the capabilities of your application. We analyzed current solutions for 2026:

Framework Interface type Performance Complexity of setup Support for native APIs Usage example
Kivy Custom (OpenGL) Medium (FPS ~30-60) Low Via Plyer or PyJNIus Games, multimedia players
BeeWare Native (Android Widgets) High (close to Java) Medium Full (via Toga) Business applications, CRM
Chaquopy Native (XML markup) Very high (at the Java level) High Full (integration with Android Studio) Applications with complex logic in Python

Kivy is the most popular choice due to its simplicity and cross-platform. It uses OpenGL for rendering, which allows you to create animations and games, but the interface will not look like native AndroidSuitable for projects where the appearance is not the same. is critical.

BeeWare โ€”an ambitious project that translates Python code into native widgets. Android. Applications look and work like native ones, but the ecosystem is still young (as of 2026, some libraries may be missing).

Chaquopy โ€” a plugin for Android Studioallows you to embed Python code in Java/Kotlin projects. This is the only way to use Python for individual modules (for example, for machine learning) in the main native application.

Which frameworks are obsolete in 2026?

In 2026 they stopped actively developing PyQt (problems with the license for Android) and SL4A (Scripting Layer for Android - does not support modern versions of the API). Their use is possible, but is fraught with compatibility problems.

Step-by-step guide: the first application on Kivy

Let's start with Kivy the most accessible option. You will need:

  • ๐Ÿ’ป Python 3.10+ (recommended 3.11 for better compatibility).
  • ๐Ÿ“ฑ Android device with USB debugging enabled or an emulator (Android Studio).
  • ๐Ÿ”ง buildozer - a tool for building APK from Python code.

Install dependencies:

pip install kivy buildozer

Create a file main.py with a simple interface:

from kivy.app import App

from kivy.uix.button import Button

class MyApp(App):

def build(self):

return Button(text="Hello Android!", size_hint=(0.5, 0.5))

MyApp().run()

Now generate an APK To do this:

  1. Create a file buildozer.spec command buildozer init.
  2. Edit it by specifying requirements = python3,kivy and title = My application.
  3. Run the build: buildozer -v android debug (may take 10-30 minutes).

The finished APK will appear in the folder bin. Install it on the device:

adb install bin/MyApp-debug.apk

Install Python 3.10+|Install Java JDK 17+|Install Android SDK (via Android Studio)|Configure environment variables for adb|Connect the device in mode debugging-->

โš ๏ธ Attention: During the first build, buildozer will download ~1.5 GB of dependencies (including Android NDKIf the build aborts with an error SSL: CERTIFICATE_VERIFY_FAILED, add to buildozer.spec line android.ndk = 25b and try again.

Working with native APIs: camera, GPS, notifications

The main problem of Python on Android is limited access to hardware. For example, to use camera, you will have to write a wrapper in Java or use libraries like Plyer:

from plyer import camera

def take_picture(instance, filename):

camera.take_picture(filename=filename, on_complete=lambda *args: print("Photo saved!"))

camera.request_permissions(take_picture)

For GPS suitable Plyer or PyJNIus (bridge to Java code):

from jnius import autoclass

Gaining access to Android LocationManager

LocationManager = autoclass('android.location.LocationManager')

context = autoclass('org.kivy.android.PythonActivity').mActivity

location_manager = context.getSystemService(LocationManager.GPS_PROVIDER)

With notifications it's easier - use plyer.notification:

from plyer import notification

notification.notify(

title="Greetings from Python!",

message="This is a notification from your application",

app_name="MyApp"

)

For complex tasks (for example, working with Bluetooth Low Energyyou will have to write Java code and connect it with Python via PyJNIus or Chaquopy. An alternative is to use ready-made solutions like bleak (but they may not support all functions Android 14+).

android.permissions = INTERNET, CAMERA, ACCESS_FINE_LOCATION, READ_CONTACTS

Without this, the application will crash when trying to access protected data.-->

Performance optimization: how to speed up Python on Android

Python code on Android is slower than native due to the interpreter. But there are ways to speed it up:

  1. Use Cython - compile critical parts of the code in C:
    # file module.pyx
    

    def heavy_calculation(int n):

    cdef int i, result = 0

    for i in range(n):

    result += i * i

    return result

    Then compile it and import it into the main one code.

  2. Move heavy calculations to C++ via PyJNIus or Chaquopy.
  3. Disable unnecessary modules to buildozer.spec:
    # Remove unnecessary ones dependencies
    

    requirements = python3,kivy,sqlalchemy # instead of python3,kivy,pandas,numpy,...

  4. Use multiprocessing instead threading - because GIL (Global Interpreter Lock) threads in Python do not provide a performance boost on multitasking operations.

A critical mistake of many beginners: trying to use numpy or pandas without optimization. These libraries are compiled into a full APK, increasing its size to 100+ MB. Instead, use lightweight alternatives like micronumpy or process the data on the server.

Problem Solution Performance gain
Slow cycles Cython or Numba 5-20 times
UI freezing Moving logic to a separate process interface remains responsive
Large size APK Exclusion of unnecessary libraries from 100 MB to 15-20 MB

Building and publishing on Google Play: 2026 requirements

Before publishing in Google Play your application must meet several requirements:

  • ๐Ÿ“„ 64-bit support โ€” mandatory since 2019. buildozer.spec add:
    android.arch = armeabi-v7a, arm64-v8a
  • ๐Ÿ”’ Privacy Policy - even if the application does not collect data, it must be indicated in the listing.
  • ๐Ÿ“ฆ APK size โ€”if more than 150 MB, you will need to use Android App Bundle (.aab).
  • ๐Ÿ”„ Target API level โ€”for 2026 this is android.api = 34 (Android 14).

Publishing process:

  1. Collect the release version:
    buildozer android release
  2. Sign the APK using jarsigner or via Android Studio.
  3. Upload to Google Play Consoleby filling out:
    • Screenshots (minimum 2, recommended 5+).
    • Description in Russian and English.
    • Content classification (even for โ€œ12+โ€ you need to fill out a questionnaire).
โš ๏ธ Attention: From 2026 Google Play requires specifying data collection type (even if you only use standard resolutions like INTERNET). In the publication form, select โ€œNo, my app doesnโ€™t collect any user dataโ€ or describe in detail what data you collect.
๐Ÿ’ก

Use Android App Bundle (.aab) instead of APK - this reduces the size of the file uploaded by the user by 20-30% due to dynamic delivery of only the necessary ones resources.

Alternatives: when Python is not suitable

Python on Android is not a panacea. In some cases, it is better to choose other tools:

  • ๐ŸŽฎ Games with 3D graphics โ†’ Unity (C#) or Godot (GDScript/C#).
  • ๐Ÿ“ˆ Compute-intensive applications โ†’ Kotlin + C++ (via Android NDK).
  • ๐Ÿ”’ Banking/medical applications โ†’ native development only (security requirements).
  • โšก Applications for weak devices (for example, Android Go) โ†’ Flutter or Kotlin.

If you need hybrid approach (part of the logic in Python, native interface), consider:

  • Chaquopy โ€” for embedding Python in a Java/Kotlin project.
  • Flutter + Python โ€”through flutter_python (experimental support).
  • React Native + Python โ€”through a bridge python-bridge.

For example, this is how you can organize interaction between Kotlin and Python in Chaquopy:

// In Kotlin (MainActivity.kt)

val python = Python.getInstance()

val module = python.getModule("script")

val result = module.callAttr("calculate", 10, 20).toJava(Int::class.java)

# In Python (script.py)

def calculate(a, b):

return a + b

FAQ: answers to frequently asked questions

Is it possible to write in Python for iOS and Android at the same time?

Yes, but with reservations. Kivy and BeeWare support cross-platform, but iOS requires Mac With Xcode an Apple developer account ($99 per year). Assembly for iOS is more difficult due to restrictions Apple on dynamic code generation (Python is interpreted on the fly). โ€” Chaquopy s Xamarin, but this will require knowledge of C#.

How to update Python in an already published application?

You cannot update the Python version in an APK - you will have to release a new version of the application. To avoid problems:

  1. Fix the Python version in buildozer.spec (requirements = python3==3.11.0).
  2. Test on several versions Android (minimum supported - Android 8.0 for 2026).
  3. Use pip freeze > requirements.txtto fix the versions of all libraries.
Is it true that Google Play blocks Python applications?

No, but there are nuances. Google Play does not block applications by programming language, however:

  • Applications with large APK sizes (for example, due to enabled numpy/pandass) may receive a warning about "non-optimal size".
  • If your application uses exec() or dynamic code loading, this may raise suspicions of a violation of the security policy (section "Deceptive Behavior").
  • Assemblies through buildozer sometimes labeled as "potentially hazardous" due to use NDK. In this case, you will have to send an appeal explaining that this is a legitimate application.

To avoid problems, publish the application as "Beta" and test it on a group of users before full release.

Can I use TensorFlow/PyTorch on Android via Python?

Yes, but with restrictions. To do this:

  1. Use tensorflow-lite or torchscript light versions of libraries.
  2. Compile the model in advance (not on the device!).
  3. B buildozer.spec specify:
    requirements = python3, https://github.com/kivy/python-for-android/archive/master.zip, tensorflow==2.12.0

Example of loading a model:

import tensorflow as tf

Loading the model from assets

model_path = "./assets/model.tflite"

interpreter = tf.lite.Interpreter(model_path=model_path)

โš ๏ธ Attention: Models TensorFlow weigh tens of megabytes. Optimize them via TFLite Converter and specify android.include_exts = tflite to buildozer.spec.

How to debug Python code on Android?

Debugging methods:

  • Logs via adb:
    adb logcat | grep python
  • Use pdb โ€”insert into the code:
    import pdb; pdb.set_trace()

    and connect via adb forward tcp:5000 tcp:5000.

  • Chaquopy Debugger โ€”if you use Android Studio, you can set breakpoints directly in the Python code.
  • Remote debugging via VS Code โ€”with a plugin Python Debugger and settings launch.json.