1
0

build: android: use Java 17, as before debian upgrade :/

When building on debian 12, we were using Java 17.
On debian 13, Java 17 is not packaged anymore, instead there is Java 21 and 25.
Ideally we should upgrade to Java 21 and just install it from apt.

However old Gradle is not compatible with new Java, so we have to upgrade Gradle for that.
- see https://docs.gradle.org/current/userguide/compatibility.html

Old Gradle is giving build errors with Java 21:
```
Could not compile build file '/home/user/wspace/electrum/.buildozer_qml/android/platform/build-arm64-v8a/dists/Electrum/build.gradle'.
> startup failed:
General error during conversion: Unsupported class file major version 65

java.lang.IllegalArgumentException: Unsupported class file major version 65
```

for our p4a fork, I tried to cherry-pick stuff from upstream:
- 17bf532279
- https://github.com/kivy/python-for-android/pull/3172
    a8f2ca1c5b
- see a01269f779...846a109487

That seems sufficient to upgrade Gradle as far as p4a is concerned.

However that still did not work yet:
- contrib/android/make_barcode_scanner.sh fails, as
    markusfisch/zxing-cpp and markusfisch/CameraView
    are also using too old gradle versions for Java 21
    - it seems they are intentionally doing this to maintain compat with Android 4:
        see d98ed5d0be

So for now maybe the path of least resistance is to downgrade to Java 17 :(
This commit is contained in:
SomberNight
2026-01-30 16:45:13 +00:00
parent 35ca9b4fff
commit 4da7b7f55d

View File

@@ -91,11 +91,42 @@ RUN mkdir --parents "${ANDROID_SDK_HOME}/.android/" \
&& echo '### User Sources for Android SDK Manager' \
> "${ANDROID_SDK_HOME}/.android/repositories.cfg"
# accept Android licenses (JDK necessary!)
# download Java-17 (debian 13 only packages Java-21 and Java-25)
# - we download the amd64 binaries from debian 12 repos
# - we should try to upgrade to Java-21...
# - the main blocker seems to be having to update Gradle (to a version compatible with Java-21)
# - make_barcode_scanner.sh: markusfisch/{zxing-cpp, ...} pins old Gradle
ENV JAVA_JRE_DL_URL="https://snapshot.debian.org/archive/debian/20260130T143028Z/pool/main/o/openjdk-17/openjdk-17-jre-headless_17.0.18+8-1~deb12u1_amd64.deb"
ENV JAVA_JRE_ARCHIVE="openjdk-17-jre-headless.deb"
ENV JAVA_JRE_HASH="5bc36cbb4e383dbea4168d57b5fd9b42375ec8837dd62a1d56677632c3c960e0"
ENV JAVA_JDK_DL_URL="https://snapshot.debian.org/archive/debian/20260130T143028Z/pool/main/o/openjdk-17/openjdk-17-jdk-headless_17.0.18+8-1~deb12u1_amd64.deb"
ENV JAVA_JDK_ARCHIVE="openjdk-17-jdk-headless.deb"
ENV JAVA_JDK_HASH="8841044caa66860a71039342fe3c02b7853b61c518e05970e501faa215b1788a"
RUN apt -y update -qq \
&& apt -y install -qq --no-install-recommends --allow-downgrades \
openjdk-21-jdk-headless \
&& apt -y autoremove
&& apt -y install -qq --no-install-recommends \
ca-certificates-java \
java-common \
libcups2 \
libfontconfig1 \
liblcms2-2 \
libjpeg62-turbo \
libnss3 \
libasound2 \
libfreetype6 \
libharfbuzz0b \
libpcsclite1 \
&& apt -y autoremove \
&& cd /opt \
&& curl --location --progress-bar "${JAVA_JRE_DL_URL}" --output "${JAVA_JRE_ARCHIVE}" \
&& echo "${JAVA_JRE_HASH} ${JAVA_JRE_ARCHIVE}" | sha256sum -c - \
&& dpkg -i "${JAVA_JRE_ARCHIVE}" \
&& rm "${JAVA_JRE_ARCHIVE}" \
&& curl --location --progress-bar "${JAVA_JDK_DL_URL}" --output "${JAVA_JDK_ARCHIVE}" \
&& echo "${JAVA_JDK_HASH} ${JAVA_JDK_ARCHIVE}" | sha256sum -c - \
&& dpkg -i "${JAVA_JDK_ARCHIVE}" \
&& rm "${JAVA_JDK_ARCHIVE}"
# accept Android licenses (JDK necessary!)
RUN yes | ${ANDROID_SDK_MANAGER} --licenses > /dev/null