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.3.tar.gz (35.7 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.3-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: apkpy-0.2.3.tar.gz
  • Upload date:
  • Size: 35.7 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.3.tar.gz
Algorithm Hash digest
SHA256 1ea717c0d22090504e52ebaff4d5694e74b2f8de6f6547794d55276c89e77763
MD5 c67b2a707a50c1e552d69eb169d86f69
BLAKE2b-256 5944bbe04b96cf700866ad8ae12d1503bd2bd6c868068c043bfd42685375f27a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: apkpy-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 37.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e79c3b133c6bd7e0dcebe861680642f1b4bb4bc4ec068c12b862ab94ce229bc6
MD5 b75802f04f720b3b2c2008a16c54a89d
BLAKE2b-256 a14e642be37e4574b917f1bd15e9dbf96f6b18660023d4ed39f77376fd2ef6bc

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