Skip to content

Make Claude Code cloud sessions build-capable: JDK 25 + Android SDK setup (env config) #137

Description

@almothafar

Problem

Claude Code cloud sessions currently cannot build this project locally — changes are only verified by opening a PR so GitHub Actions runs (that's how #136 was verified). Three gaps, observed in a real session (2026-07-12):

  1. Network egress policy blocks the Gradle distribution. The wrapper fetches gradle-9.5.1-bin.zip from services.gradle.org, which redirects to a GitHub release asset (github.com/gradle/gradle-distributions/releases/...) — the proxy returns 403 for that host.
  2. The container ships JDK 21 (Ubuntu 24.04 default), but app/build.gradle sets sourceCompatibility/targetCompatibility = Java 25 — same reason CI installs Temurin 25 explicitly.
  3. No Android SDK in the container (no ANDROID_HOME, no platforms/build-tools).

Fix — three steps, all in one environment-settings dialog

Where to change it (exact navigation)

There is no separate "Environments" page — everything lives in one dialog:

  1. Go to claude.ai/code.
  2. Click the cloud icon showing the current environment's name to open the environment selector.
  3. Hover over the environment used for this repo's sessions and click the settings (gear) icon that appears on its right.
  4. The edit dialog contains all three fields used below: Network access, Environment variables (.env format), and Setup script.

Changing allowed domains or the setup script rebuilds the cached environment snapshot — the next session start re-runs setup once, then later sessions reuse the snapshot.

Docs: https://code.claude.com/docs/en/claude-code-on-the-web

Step 1: Network allowlist

The default Trusted level already includes services.gradle.org, plugins.gradle.org, repo.maven.apache.org, github.com, objects.githubusercontent.com, and release-assets.githubusercontent.com — i.e. everything Gradle itself needs. What's missing for an Android build is only Google's SDK/Maven host and Adoptium (for JDK 25).

In the Network access selector choose Custom, keep the Trusted defaults included, and add these three lines to Allowed domains:

dl.google.com
maven.google.com
api.adoptium.net

⚠️ Check the current level while in the dialog: the 2026-07-12 session got 403 on github.com release assets even though that host is in the Trusted defaults, which suggests the environment is currently on a stricter setting (not Trusted). "Custom + include defaults + the three domains above" fixes both problems at once.

Step 2: JDK 25

Either install Temurin 25 in the setup script and export JAVA_HOME, or (nicer, helps every contributor) adopt Gradle toolchains in the repo:

// settings.gradle
plugins {
    id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}
// app/build.gradle
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(25)
    }
}

With the toolchain approach Gradle auto-provisions JDK 25 regardless of the launcher JVM (still needs api.adoptium.net from Step 1).

Step 3: Android SDK (Setup script field)

export ANDROID_HOME="$HOME/android-sdk"
mkdir -p "$ANDROID_HOME/cmdline-tools"
curl -o /tmp/clt.zip "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip"
unzip -q /tmp/clt.zip -d "$ANDROID_HOME/cmdline-tools"
mv "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest"
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "platform-tools" "platforms;android-36"

Plus ANDROID_HOME=/root/android-sdk (setup scripts run as root) in the Environment variables field. platforms;android-36 matches compileSdk = 36; AGP fetches matching build-tools automatically. Alternatively write sdk.dir into local.properties from the setup script.

Plan

  1. Update the network access level + allowed domains (manual, dialog above).
  2. In a fresh session, write + verify the setup script end-to-end (./gradlew test assembleDebug must pass), then save it into the environment config.
  3. Decide on the toolchain option (repo change) vs. script-installed JDK (env-only change).
  4. Optionally document the setup in the README's Building from Source section (also relevant to Fill out the Installation section of README.md #3).

Acceptance criteria

  • A fresh Claude Code cloud session can run ./gradlew test and ./gradlew assembleDebug successfully
  • Setup is scripted in the environment config (no manual per-session steps)
  • Decision recorded: Gradle toolchain in-repo vs. setup-script JDK

Notes

  • CI (android-ci.yml) stays the source of truth for PR verification; this is about faster in-session iteration (build, lint, unit tests) before a PR exists.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions