Android build now works end-to-end: JDK pin, p4a venv fix, kivy recipe
- build.sh: pin JAVA_HOME to java-17-openjdk for the build only (Gradle 8.14.3 can't parse this machine's default java-26 class files). - build.sh: delete p4a's internal pymodules venv before every run — it re-runs `python -m venv` without --clear on each build and corrupts its own pip (confirmed two dist-info dirs coexisting). - CLAUDE.md / android/README.md: document all three build-tooling fixes from this session (kivy python_depends, p4a venv corruption, JDK pin) so a future session/rebuild doesn't have to re-diagnose them. Confirmed: full BUILD SUCCESSFUL Gradle run, APK produced at android/bin/eventtracker-0.1-arm64-v8a-debug.apk. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
cd9f9456e9
commit
5e7cb1ced9
3 changed files with 100 additions and 9 deletions
|
|
@ -24,6 +24,7 @@ Run on the Linux machine you're building from (not the phone):
|
|||
```sh
|
||||
command -v buildozer && buildozer version 2>&1
|
||||
command -v java && java -version 2>&1
|
||||
archlinux-java status 2>&1
|
||||
python3 -c "import cython; print('cython:', cython.__version__)" 2>&1
|
||||
```
|
||||
|
||||
|
|
@ -32,9 +33,19 @@ python3 -c "import cython; print('cython:', cython.__version__)" 2>&1
|
|||
**Arch / EndeavourOS:**
|
||||
|
||||
```sh
|
||||
sudo pacman -S --needed jdk-openjdk
|
||||
sudo pacman -S --needed jdk17-openjdk
|
||||
```
|
||||
|
||||
Gradle (pulled in by buildozer/p4a) needs a JDK it actually supports —
|
||||
`jdk-openjdk` on a rolling-release system tracks whatever's newest, and
|
||||
a too-new JDK breaks Gradle's build-script compiler with `Unsupported
|
||||
class file major version …`. `jdk17-openjdk` specifically, installed
|
||||
alongside whatever your system default is (`archlinux-java status`
|
||||
lists both — no need to switch the default). `build.sh` points this
|
||||
build at it via `JAVA_HOME` on its own; if `archlinux-java status` shows
|
||||
it under a different name on your machine, update
|
||||
`JAVA_HOME_FOR_BUILD` at the top of `build.sh` to match.
|
||||
|
||||
buildozer and cython go in an isolated venv, not system Python — see
|
||||
next step. (No `pip install --break-system-packages`; that pollutes the
|
||||
system Python site-packages for no reason when a venv does the job.)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,18 @@
|
|||
# buildozer through it directly. Usage: ./build.sh android debug
|
||||
set -euo pipefail
|
||||
|
||||
# ---- Configuration ----
|
||||
# Gradle 8.14.3 (pulled in by this p4a/buildozer version) ships a
|
||||
# Groovy/ASM build-script compiler that doesn't understand class files
|
||||
# newer than it was built against. This system's `java` default is
|
||||
# java-26-openjdk (`archlinux-java status`), and Gradle chokes on it:
|
||||
# BUG! ... Unsupported class file major version 70
|
||||
# java-17-openjdk is also installed on this machine and works — set only
|
||||
# for this build, via JAVA_HOME below, so the system-wide default JDK
|
||||
# (used by everything else) is untouched. If Arch's package layout ever
|
||||
# changes this path, `archlinux-java status` shows the current one.
|
||||
JAVA_HOME_FOR_BUILD="/usr/lib/jvm/java-17-openjdk"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
VENV_BIN="$SCRIPT_DIR/build/venv/bin"
|
||||
BUILDOZER="$VENV_BIN/buildozer"
|
||||
|
|
@ -12,7 +24,14 @@ if [ ! -x "$BUILDOZER" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$JAVA_HOME_FOR_BUILD" ]; then
|
||||
echo "Expected JDK not found at $JAVA_HOME_FOR_BUILD — run 'archlinux-java status' and update JAVA_HOME_FOR_BUILD in this script." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
export JAVA_HOME="$JAVA_HOME_FOR_BUILD"
|
||||
export PATH="$JAVA_HOME/bin:$PATH"
|
||||
# Running buildozer by absolute path skips everything `source venv/bin/activate`
|
||||
# normally sets up, so it's replicated by hand:
|
||||
# - PATH: buildozer shells out to find tools like `cython`, which only
|
||||
|
|
@ -23,4 +42,26 @@ cd "$SCRIPT_DIR"
|
|||
# a venv, uses --user, and pip refuses (no user site-packages in a venv).
|
||||
export PATH="$VENV_BIN:$PATH"
|
||||
export VIRTUAL_ENV="$SCRIPT_DIR/build/venv"
|
||||
|
||||
# p4a creates its OWN throwaway venv per arch (.buildozer/.../build/venv,
|
||||
# distinct from our build/venv above) to pip-install pure-Python deps for
|
||||
# the app, and unconditionally re-runs `python -m venv venv` over it on
|
||||
# every single build — without --clear. The first time, ensurepip bundles
|
||||
# whatever pip version shipped with this system's Python (e.g. 25.3); if
|
||||
# a previous build then ran `pip install -U pip` inside it (p4a does this
|
||||
# every time too), the NEXT build's `python -m venv` re-invokes ensurepip,
|
||||
# which unpacks its older bundled pip back over the newer one WITHOUT
|
||||
# removing the newer version's now-orphaned files — two dist-info dirs
|
||||
# end up coexisting, and a newer file (e.g. build_env/installer.py,
|
||||
# importing a class only the newer pip's exceptions.py defines) can end
|
||||
# up paired with an older file that doesn't define it, e.g.:
|
||||
# ImportError: cannot import name 'BuildDependencyInstallError' from
|
||||
# 'pip._internal.exceptions'
|
||||
# Confirmed by hand: pip-25.3.dist-info and pip-26.2.1.dist-info both
|
||||
# present in the same site-packages after a second build. Deleting that
|
||||
# venv before every build keeps it single-version and costs a few
|
||||
# seconds (pip + Cython reinstall) — cheap next to the SDK/NDK/recipe
|
||||
# build state, which this leaves untouched.
|
||||
rm -rf "$SCRIPT_DIR"/.buildozer/android/platform/build-*/build/venv
|
||||
|
||||
exec "$BUILDOZER" "$@"
|
||||
|
|
|
|||
Loading…
Reference in a new issue