Skip to content

Proposal: Android-Specific Metadata Support in Recipes #3179

Open

Description

@Novfensec

Introduce support in python-for-android to parse Android-specific metadata from pyproject.toml of pip-installed packages. This enables modular bundling of assets into APK builds, allowing packages to contribute platform-native components directly.

Example pyproject.toml Layout

[tool.python-for-android.android]
src = "android/src/"
res = "android/res/"
extra_manifest_xml = "android/extra_manifest.xml"
extra_manifest_application_xml= "android/extra_manifest_application.xml"
activities = [
    {
        "name": "org.package.android.MyActivity",
        "process": ":package_process",
    }
]
proguard = "android/proguard-rules.txt"
jniLibs = "android/jni/"
assets = "android/assets/"
resources = "android/resources"

etc. Etc.

How It Works

  • During dependency resolution (p4a.recipe or pip stage), check for [tool.python-for-android.android] in pyproject.toml.
  • Resolve declared paths from the site-packages directory.
  • Inject collected files into dists/<your_app>/build/ before Gradle build.

Please consider this.

THANKS!!

Activity

  1. added
    need-discussionThe issue or pull request needs a discussion to take a team decission
    on Jul 24, 2025
  2. kengoon commented on Dec 6, 2025

    @kengoon
    Contributor

    @kuzeyron I want to take on this, but I don't know if the approach I have in mind is okay. Here's what I'm thinking: directly under this code:

    run_pymodules_install(
    ctx, arch, python_modules, project_dir,
    ignore_setup_py=ignore_project_setup_py
    )

    p4A can loop through all installed python packages looking for a android.toml or in the root folder of each package or in root/android. When found it loads toml file and extracts the java src file only and copy it to ctx.javaclass_dir.

    The reason I said java src file only is because modifying xml or adding resources can conflict with what the user want's to modify themselves.

  3. kengoon commented on Dec 6, 2025

    @kengoon
    Contributor

    Something even better, --requirements args can be modified to accept extra arguments. e.g

    android.requirements = python,kivy,mypackage:android,otherpackage-with-version==1.2:java

    where android and java are the directory inside the packages containing the java files in a java compliant package directory. then we can extract them and put in environ just like the way the versions are stored in environ also. and then copy them to ctx.javaclass_dir.

    @kuzeyron what do you think?

  4. kuzeyron commented on Dec 7, 2025

    @kuzeyron
    Contributor

    Sure, why not? Make sure to write a proper documentation of this if you proceed with this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    need-discussionThe issue or pull request needs a discussion to take a team decission

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions