From 4da7b7f55d85f11d84cfb5995bd6ad1d9d9cb311 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 30 Jan 2026 16:45:13 +0000 Subject: [PATCH] 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: - https://github.com/kivy/python-for-android/commit/17bf5322791ec8cec85836fbe906e63664a05445 - https://github.com/kivy/python-for-android/pull/3172 https://github.com/kivy/python-for-android/commit/a8f2ca1c5b1bb6696b47fdf2c052285e116e0ebe - see https://github.com/SomberNight/python-for-android/compare/a01269f7799587ad74ee40e0b642d917b8db7d4e...846a1094874aeb64b623fa746222a41851245271 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 https://github.com/markusfisch/zxing-cpp/commit/d98ed5d0be513c4077b4c13d1f7873f141949839 So for now maybe the path of least resistance is to downgrade to Java 17 :( --- contrib/android/Dockerfile | 39 ++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/contrib/android/Dockerfile b/contrib/android/Dockerfile index 7d643e41b..d462bd4d2 100644 --- a/contrib/android/Dockerfile +++ b/contrib/android/Dockerfile @@ -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