Skip to main content

A simple framework to build Android apps using Python and CSS-like styling

Project description

🚀 ApkPy — Build Android Apps in Pure Python

ApkPy is an innovative and highly lightweight framework that enables you to build native Android applications using only Python and CSS. Forget about the steep learning curve of Java/Kotlin or dealing with messy XML layouts. With ApkPy, you write simple Python code, and we automatically generate a ready-to-compile Android Studio project (APK), complete with all native screens, styles, and behaviors!


🔥 Why use ApkPy?

  • ⚡ Zero XML and Java: Design your UI in Python. ApkPy magically converts everything into native Android Java and XML code!
  • 📱 100% Native Components: No slow WebViews here. Your buttons and text inputs are real, native Android UI elements (Activity, EditText, Button), guaranteeing flawless performance.
  • 🎨 CSS-Like Styling: Style your app using familiar CSS-inspired syntax right inside your Python file. We translate and generate all the Android .xml drawables for complex properties like custom backgrounds, colors, and even border-radius.
  • 💻 Real-Time Preview: Test and interact with your app's design directly on your computer (Windows/Mac/Linux) via a desktop simulator window before compiling.
  • 🔄 Multi-Screen Navigation: Build complex applications with multiple screens (native Activities) and seamlessly travel between them with a single command.

📥 Installation

You can quickly install ApkPy using the pip package manager:

pip install apkpy

(If you already have apkpy installed, get the brand new version using: pip install --upgrade apkpy)


🛠️ CLI Commands

ApkPy comes with essential and easy-to-use commands for your terminal:

  • apkpy start your_project_name Creates a new folder with your chosen name and sets up the base template in a file named writehere.py. This is where you can immediately start designing all your screens.

  • apkpy build This is the magic command! It parses your writehere.py and bundles your visuals and flows into a my_app_android.zip file. Inside this zip, you'll find a Complete Android Studio Project (Java source code, Manifests, XML Layouts, and Drawables built from scratch). Just extract it, open it in Android Studio, and hit play to build your APK!


📖 How it Works (Code Examples)

Completely forget about thousands of Java files. An ApkPy app looks like this:

1. Simple App: Modern Login Screen with Styles

from apkpy_lib.ui import Screen, button, label, inputs, run

# Create the screen
login_screen = Screen(id="login")

# Add elements and apply styles via ID
label("Welcome to ApkPy!", screen=login_screen)
inputs("Your username", type="text", screen=login_screen, id="user")
inputs("Your secret password", type="password", screen=login_screen, id="pass")

button("Enter App", screen=login_screen, id="btn_enter")

# Easily style using CSS (Supported: colors, border-radius, and borders)
style = """
btn_enter {
    background-color: blue;
    color: white;
    border-radius: 20px;
    border-color: none;
}
pass {
    border-radius: 10px;
    border-color: red;
}
"""

# Launch the simulator on your PC
run(start_screen=login_screen)

2. Multi-Screen & Fluent Navigation

Navigating through menus has never been easier in an Android App:

from apkpy_lib.ui import Screen, button, label, run

# Screen 1
home = Screen(id="home")
label("This is the Main Menu", screen=home)
btn_next = button("Go to Settings", screen=home)

# Screen 2
settings = Screen(id="settings")
label("You can change settings here.", screen=settings)
btn_back = button("Go Back", screen=settings)

# Make buttons travel between screens (Translates to Java Intents)
home.on_click_navigate(button=btn_next, to=settings)
settings.on_click_navigate(button=btn_back, to=home)

run(start_screen=home)

📦 Supported UI Elements

ApkPy already natively integrates fantastic Android UI tools into simple magic boxes that you can test with the inputs() command:

  • label("Just text"): A basic display text indicator.
  • button("Action"): A perfectly touch-responsive native button.
  • inputs(type="text"): The standard input box for letters and numbers.
  • inputs(type="password"): A secure input box hidden by asterisks (***).
  • inputs(type="search"): A text box formatted for searching data (includes a native clear ✕ button).
  • inputs(type="checkbox"): The classic box layout with a checkmark validation (✓).
  • inputs(type="radio", placeholder="Dog|Cat"): Exclusive selection bubbles for choices. (Just write options separated by a pipe |).
  • inputs(type="range"): A sliding bar controller to easily visualize and adjust values.

Condensing years of Android development study into mere minutes of your time. Create. Compile. Amaze with ApkPy!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apkpy-0.2.2.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apkpy-0.2.2-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file apkpy-0.2.2.tar.gz.

File metadata

  • Download URL: apkpy-0.2.2.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for apkpy-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ef72a00fe01ead2294041c62222bcc8d4b5f88a4b19385f61401850efa113771
MD5 79ff1878d6987dae36afdf9aa552bea7
BLAKE2b-256 744d09b618e166e9c6ac1b370362f5d24d7654292b6d3bcc872b2d5c6a8ce080

See more details on using hashes here.

File details

Details for the file apkpy-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: apkpy-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for apkpy-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 162a60c697bc5d6da668fb59fd3b99b4f2cadd3f75ca791039b30567e95acf65
MD5 10e34dfce885cc5d8ea5e022365c0096
BLAKE2b-256 5c44188ba388c9ebd1078954c4f50615f65047b0d8b47a36a421381273da4d8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page