diff --git a/.github/workflows/check-sdk-updates.yml b/.github/workflows/check-sdk-updates.yml index 078a7dd..7aa47f1 100644 --- a/.github/workflows/check-sdk-updates.yml +++ b/.github/workflows/check-sdk-updates.yml @@ -73,11 +73,45 @@ jobs: exit 0 fi - # Get latest available versions - # Platform packages now use MAJOR.MINOR versioning (e.g. android-36.1, - # android-37.0). Capture the optional minor component and sort by version - # so we don't truncate "37.0" to a non-existent "platforms;android-37". - LATEST_PLATFORM=$(echo "$PACKAGES" | grep 'platforms;android-' | grep -oP 'android-\K[0-9]+(\.[0-9]+)?' | sort -V | tail -1) + # Get latest available versions. + # + # Platforms must come from the repository manifest, not `sdkmanager --list`: + # preview platforms such as android-37.0 are tagged channel-0 (stable) but + # carry a element, so they appear in --list as if stable yet + # require the separate Android SDK Preview license at install time, which + # breaks the unattended Docker build. The presence of a element + # is the reliable preview marker, so we parse the manifest with a real XML + # parser and skip any platform that has one. Versions are MAJOR.MINOR + # (e.g. 36.1, 37.0). + if ! wget -q "https://dl.google.com/android/repository/repository2-3.xml" -O /tmp/android-repo.xml; then + echo "Failed to download SDK repository manifest" + echo "updated=false" >> $GITHUB_OUTPUT + exit 0 + fi + LATEST_PLATFORM=$(python3 - /tmp/android-repo.xml <<'PY' + import re, sys, xml.etree.ElementTree as ET + + def local(tag): # strip XML namespace, if any + return tag.rsplit('}', 1)[-1] + + root = ET.parse(sys.argv[1]).getroot() + best, best_key = '', None + for pkg in root.iter(): + if local(pkg.tag) != 'remotePackage' or pkg.get('obsolete') == 'true': + continue + m = re.fullmatch(r'platforms;android-(\d+(?:\.\d+)?)', pkg.get('path', '')) + if not m: + continue + # Skip previews: any descendant element marks a preview. + if any(local(e.tag) == 'codename' for e in pkg.iter()): + continue + ver = m.group(1) + key = tuple(int(x) for x in ver.split('.')) + if best_key is None or key > best_key: + best, best_key = ver, key + print(best) + PY + ) LATEST_BUILD_TOOLS=$(echo "$PACKAGES" | grep 'build-tools;' | grep -oP 'build-tools;\K[0-9.]+' | sort -V | tail -1) LATEST_NDK=$(echo "$PACKAGES" | grep -P '^\s+ndk;' | grep -oP 'ndk;\K[0-9.]+' | sort -V | tail -1) diff --git a/Dockerfile b/Dockerfile index fd975a7..7fbf9ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG VERSION=2.334.0-ubuntu-noble ARG JAVA_VERSION=21 -ARG COMPILE_SDK=37.0 +ARG COMPILE_SDK=36.1 ARG BUILD_TOOLS=37.0.0 ARG NDK_VERSION=30.0.14904198 ARG SDK_TOOLS=8512546_latest