Skip to main content

Python-for-Android (P4A) backend for Briefcase

Project description

Briefcase P4A Backend

Python-for-Android (P4A) backend for Briefcase - Build Android APKs using python-for-android directly within Briefcase's build pipeline.

Features

  • Direct P4A Integration: Uses python-for-android without Gradle or Buildozer
  • Briefcase SDK Integration: Uses Briefcase's Android SDK management system
  • Python 3.13 Compatibility: Automatically patches pyjnius 1.6.1 for Python 3.13+ compatibility
  • Framework Agnostic: Works with Kivy, console apps, and other Python frameworks

Installation

pip install git+https://github.com/pyCino/briefcase-p4a-backend.git

Usage

  1. Create a new Briefcase project:
briefcase new -t https://github.com/pyCino/briefcase-p4a-template.git --template-branch main
# Choose any GUI framework when prompted
  1. Configure for P4A backend in pyproject.toml:
[tool.briefcase.app.yourapp.android]
build_backend = "briefcase_p4a_backend"
  1. Build your Android APK:
briefcase create android p4a
briefcase build android p4a

How It Works

The P4A backend integrates with Briefcase's existing Android toolchain:

  1. Briefcase Integration: Registers as android.p4a format in Briefcase
  2. Template System: Uses cookiecutter templates for project structure
  3. SDK Management: Leverages Briefcase's Android SDK manager for tools
  4. Python 3.13 Support: Automatically applies compatibility patches to pyjnius 1.6.1 when using Python 3.13+
  5. APK Generation: Runs python-for-android with appropriate arguments and handles APK output

Requirements

  • Python 3.8+
  • Briefcase 0.3.23+
  • Linux (tested on Ubuntu 25.04+)

Configuration Options

Basic Configuration

[tool.briefcase.app.yourapp.android]
# Required: Use P4A backend
build_backend = "briefcase_p4a_backend"

Advanced Options

[tool.briefcase.app.yourapp.android]
build_backend = "briefcase_p4a_backend"

# Target architectures (defaults to armeabi-v7a, arm64-v8a)
android_archs = ["arm64-v8a"]

# API levels
android_sdk_version = "33"
android_min_sdk_version = "21"

# Custom Android activity (optional)
android_activity = "org.kivy.android.PythonActivity"

Python 3.13 Compatibility

For Python 3.13+, this backend automatically:

  • Uses local pyjnius recipe with compatibility patches applied to stable version 1.6.1
  • Patches are based on official pyjnius GitHub commit for Python 3.13 long type fixes
  • No manual intervention required - patches apply automatically when needed

Troubleshooting

Common Issues

"APK not found after build" The backend searches multiple locations for the generated APK. Check build logs for details.

Debug Commands

# Verbose build
briefcase build android p4a -v

# Clean build
briefcase build android p4a --clean

Supported frameworks

  • Kivy: Full support with kivy>=2.3.1
  • Other Frameworks: Any Python framework compatible with python-for-android

Development

# Clone and install
git clone https://github.com/pyCino/briefcase-p4a-backend.git
cd briefcase-p4a-backend
pip install -e .

# Test with sample app
briefcase new  # Create test project
# Add build_backend = "briefcase_p4a_backend" to pyproject.toml
briefcase create android p4a
briefcase build android p4a

Related Projects

License

MIT License - see LICENSE file for details.


Al pyCino - Simplifying Android development with Python

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

briefcase_p4a_backend-1.0.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

briefcase_p4a_backend-1.0.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: briefcase_p4a_backend-1.0.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for briefcase_p4a_backend-1.0.0.tar.gz
Algorithm Hash digest
SHA256 67e1236ee9e140772312a7cc7220af5c09389d5ed288fe6c0d75ffa8a995d5fe
MD5 366ea8725fdd39a1c995d8b90aaf5337
BLAKE2b-256 c8cbec500f679712527b5a31e29087bffe247e6ec0ed91d824f89fdf1de7f004

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for briefcase_p4a_backend-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3ea021363d4cc09f71ab3588c1ac7175d9b1b6c846629d84352bb328036e8dc
MD5 2ebe0ec78c5cd391e561b1cdc183cad6
BLAKE2b-256 b6c059855f66a220c73f24e3600aa8b583e7712620f4b868288594ec494a8955

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