Skip to main content

A pure Python Android APK builder with auto SDK/NDK management

Project description

AndroBuilder

A pure Python Android APK builder with automatic SDK/NDK management. Build Android apps without Gradle!

Features

  • ๐Ÿš€ Pure Python - No Gradle or Android Studio required
  • ๐Ÿ“ฆ Auto SDK/NDK Management - Automatically downloads and installs required tools
  • ๐Ÿ”ง Full Control - Complete control over the build process
  • ๐ŸŽฏ Multi-DEX Support - Handle large apps with 65k+ methods
  • ๐Ÿ”’ ProGuard Integration - Code shrinking and obfuscation
  • ๐Ÿ“ฑ NDK Support - Compile native C/C++ libraries
  • โšก Fast Builds - Optimized build pipeline
  • ๐ŸŽจ AAPT2 Support - Modern resource compilation
  • ๐Ÿ” Flexible Signing - Debug or release keystores

Installation

pip install androbuilder

Quick Start

Python API

from androbuilder import Builder

# Simple build
builder = Builder(path="./MyApp", sdk="34")
apk_path = builder.build("./output")
print(f"APK built: {apk_path}")

# Advanced build
builder = Builder(
    path="./MyApp",
    sdk="34",                    # Auto-downloads SDK 34
    ndk="25.1.8937393",         # Auto-downloads NDK
    multidex=True,
    proguard=True,
    proguardconfig={
        'rules': ['proguard-rules.pro'],
        'optimize': True
    },
    sign=True,
    signconfig={
        'path': 'release.keystore',
        'alias': 'mykey',
        'password': 'mypassword'
    },
    versioncode=2,
    versionname="1.0.1",
    verbose=True
)

apk_path = builder.build("./output")

Command Line

# Basic build
androbuilder build ./MyApp

# Advanced build
androbuilder build ./MyApp \
    --sdk 34 \
    --ndk 25.1.8937393 \
    --multidex \
    --proguard \
    --signconfig release.keystore mykey mypass \
    --verbose \
    --output ./dist

# Show project info
androbuilder info ./MyApp

# Show version
androbuilder version

Project Structure

Your Android project should have this structure:

MyApp/
โ”œโ”€โ”€ AndroidManifest.xml
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ com/
โ”‚       โ””โ”€โ”€ example/
โ”‚           โ””โ”€โ”€ app/
โ”‚               โ””โ”€โ”€ MainActivity.java
โ”œโ”€โ”€ res/
โ”‚   โ”œโ”€โ”€ layout/
โ”‚   โ”‚   โ””โ”€โ”€ activity_main.xml
โ”‚   โ”œโ”€โ”€ values/
โ”‚   โ”‚   โ””โ”€โ”€ strings.xml
โ”‚   โ””โ”€โ”€ drawable/
โ”œโ”€โ”€ libs/                    # Optional: JAR dependencies
โ”œโ”€โ”€ jni/                     # Optional: Native code
โ”‚   โ”œโ”€โ”€ Android.mk
โ”‚   โ””โ”€โ”€ native-lib.cpp
โ””โ”€โ”€ proguard-rules.pro      # Optional: ProGuard rules

Configuration Options

Builder Parameters

Parameter Type Default Description
path str Required Path to Android project
sdk str None SDK version or path
ndk str None NDK version or path
multidex bool False Enable multi-DEX
proguard bool False Enable ProGuard
proguardconfig dict None ProGuard configuration
sign bool True Sign the APK
signconfig dict None Signing configuration
buildtools str "34.0.0" Build tools version
target str "34" Target SDK version
minsdkversion int 21 Minimum SDK version
versioncode int 1 Version code
versionname str "1.0.0" Version name
aapt2 bool True Use AAPT2
optimize bool True Optimize APK
verbose bool False Verbose output
clean bool True Clean before build
java_home str None Path to java home
java_path str None Path to java
allow_missing_resources bool False Skips missing resources exception

Sign Configuration

signconfig = {
    'path': 'my-release.keystore',  # Path to keystore
    'alias': 'mykey',                # Key alias
    'password': 'mypassword',        # Key password
    'storepass': 'storepassword'     # Store password (optional)
}

ProGuard Configuration

proguardconfig = {
    'rules': ['proguard-rules.pro'],  # Rule files
    'optimize': True                   # Enable optimization
}

SDK/NDK Management

AndroBuilder automatically manages SDK and NDK installations:

Automatic Download

# Downloads SDK 34 automatically
builder = Builder(path="./MyApp", sdk="34")

# Downloads NDK 25.1.8937393 automatically
builder = Builder(path="./MyApp", sdk="34", ndk="25.1.8937393")

SDKs are installed in: <project>/.androbuilder/sdk/ NDKs are installed in: <project>/.androbuilder/ndk/

Using Existing SDK/NDK

# Use existing SDK
builder = Builder(path="./MyApp", sdk="/path/to/android-sdk")

# Use existing NDK
builder = Builder(path="./MyApp", ndk="/path/to/android-ndk")

SDK Detection

AndroBuilder automatically detects SDKs in:

  • $ANDROID_HOME
  • $ANDROID_SDK_ROOT
  • ~/Android/Sdk
  • ~/Library/Android/sdk
  • <project>/.androbuilder/sdk

Examples

Basic App

from androbuilder import Builder

builder = Builder(
    path="./HelloWorld",
    sdk="34",
    versionname="1.0.0",
    verbose=True
)

apk = builder.build("./output")

App with Native Code

from androbuilder import Builder

builder = Builder(
    path="./NativeApp",
    sdk="34",
    ndk="25.1.8937393",
    verbose=True
)

apk = builder.build("./output")

Release Build

from androbuilder import Builder

builder = Builder(
    path="./MyApp",
    sdk="34",
    proguard=True,
    proguardconfig={'rules': ['proguard-rules.pro']},
    sign=True,
    signconfig={
        'path': 'release.keystore',
        'alias': 'release',
        'password': 'release123'
    },
    versioncode=10,
    versionname="1.0.9",
    optimize=True
)

apk = builder.build("./release")

Large App with Multi-DEX

from androbuilder import Builder

builder = Builder(
    path="./LargeApp",
    sdk="34",
    multidex=True,
    minsdkversion=21,
    verbose=True
)

apk = builder.build("./output")

Error Handling

from androbuilder import Builder, BuildError, SDKError

try:
    builder = Builder(path="./MyApp", sdk="34")
    apk = builder.build("./output")
except SDKError as e:
    print(f"SDK error: {e}")
except BuildError as e:
    print(f"Build error: {e}")

Requirements

  • Python 3.7+
  • Java JDK 8+ (for javac and keytool)
  • Internet connection (for SDK/NDK downloads)

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

LICENSE (MIT)

MIT License

Copyright (c) 2025 Rustamov Humoyun Mirzo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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

androbuilder-1.0.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

androbuilder-1.0.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file androbuilder-1.0.0.tar.gz.

File metadata

  • Download URL: androbuilder-1.0.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for androbuilder-1.0.0.tar.gz
Algorithm Hash digest
SHA256 67338f4aea4f127f1f2f81cf8675e2ecca8bf2f6c3bfb72fe53387f26840dd86
MD5 5c007528ed74eb399e1ddfe5f4839ce2
BLAKE2b-256 cafde6930afe170c8f43390d148ee97daaa8f51d951e54112defcb514f939619

See more details on using hashes here.

File details

Details for the file androbuilder-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: androbuilder-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for androbuilder-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4424b2dc9d67b5d421df9a3fc7927b42b5aa7a1ee83f66d9c12570506130dd4
MD5 caa9dfb7354d06abe3c28f845983c081
BLAKE2b-256 19814d71a8dd57c76136b9df6382f5541eb88e706a0d40e3c9ca5f1e03831dd7

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