Skip to content
Latchkey

Gradle Toolchain Auto-Provisioning Failed - Fix JDK Download in CI

Gradle tried to auto-provision a JDK for a Java toolchain and could not. Either no local JDK matched and the download failed (a transient network/provider blip), or no toolchain download repository is configured so Gradle has nowhere to fetch from.

What this error means

The build fails resolving a toolchain with Unable to download toolchain matching the requirements (languageVersion=21, ...), or No matching toolchains found ... and auto-provisioning failed / Toolchain download repositories have not been configured.

gradle output
> Could not determine the dependencies of task ':app:compileJava'.
> Failed to calculate the value of task ':app:compileJava' property 'javaCompiler'.
   > Unable to download toolchain matching the requirements
     ({languageVersion=21, vendor=any, implementation=vendor-specific}) ...
       > Read timed out

Common causes

Transient download failure from the toolchain provider

Auto-provisioning downloads a JDK from a remote provider (e.g. the Foojay resolver). A network blip or provider slowness times out the fetch - usually clears on retry.

No toolchain download repository configured

Modern Gradle requires a toolchain resolver plugin (e.g. foojay-resolver-convention) in settings. Without it, no local match means auto-provisioning has no source and fails hard.

How to fix it

Configure a toolchain resolver and provide the JDK in CI

Add the Foojay resolver in settings and pre-install the JDK so provisioning can match locally without a download.

settings.gradle.kts
// settings.gradle.kts
plugins {
    id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}

Pre-provision the toolchain JDK to avoid a live download

Install the JDK with setup-java and let Gradle detect it instead of downloading.

.github/workflows/ci.yml
- uses: actions/setup-java@v4
  with:
    distribution: temurin
    java-version: '21'
- run: ./gradlew build -Dorg.gradle.java.installations.auto-download=false

How to prevent it

  • Add the foojay-resolver-convention plugin so toolchains can resolve.
  • Pre-install toolchain JDKs in CI and let Gradle detect them (avoid live downloads).
  • Cache ~/.gradle/jdks so a provisioned toolchain is reused across jobs.

Frequently asked questions

What causes ""Unable to download toolchain""?
Auto-provisioning downloads a JDK from a remote provider (e.g. the Foojay resolver). A network blip or provider slowness times out the fetch - usually clears on retry.
How do I fix "Unable to download toolchain"?
Add the Foojay resolver in settings and pre-install the JDK so provisioning can match locally without a download.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card