kivy / kivy/python-for-android

Build Process Enhancement: Exclude redundant source files from `dists` directory

Open
#3,258 0 comments 0 reactions 0 assignees View on GitHub
Priority: High RELEASE BLOCKER
Dominant language
Python
Stars
8.9k
Forks
2k
Avg merge
12h 20m
Merged PRs (30d)
9

Description

**Problem Description**

The current `assemble_distribution` method in the `SDLGradleBootstrap` (and other bootstraps) copies the entire temporary build directory into the final `dists/` directory.

This process works reliably, but it results in a `dists` directory that contains a large number of redundant files. Specifically, it includes the complete C/C++ source code for all the `BootstrapNDKRecipe` dependencies (like SDL2, SDL2_image, etc.) in the `jni/` subfolder, as well as intermediate object files in `obj/`.

This is unnecessary because these source files have already been compiled by `ndk-build` into the final `.so` libraries located in the `libs/` directory. The subsequent Gradle build step only uses these pre-compiled libraries and does not re-compile the C/C++ source.

This behavior has a few negative consequences:
1. **Increased Disk Usage:** It significantly inflates the size of the distribution, which can be problematic in CI/CD environments or on systems with limited disk space.
2. **Slower Build Times:** The file I/O for copying of unnecessary source code adds a small but noticeable delay to the build process.
3. **Confusing Project Structure:** The presence of the `jni/` sources in the final Gradle project can be misleading, suggesting that Gradle might be compiling them, which it is not. A cleaner project structure would be easier to debug and understand.

**Note:** This issue does **not** affect the final size of the APK, as the Android packaging tools correctly exclude the source code. This is purely an enhancement for the intermediate build process.

Contributor guide

Open the contributing guide

Research direction

Start by locating the assemble_distribution method in SDLGradleBootstrap and the other bootstrap implementations. Trace how the temporary build directory is copied into dists/, then verify that the distribution retains compiled libraries while excluding the redundant jni/ sources and obj/ files. Confirm the change with the project’s available build or distribution checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, python
Domain
build-system, mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.