Skip to content
Latchkey

Gradle "No matching toolchains found for requested specification" in CI

Your build requests a specific Java toolchain (for example, language version 21) but no installed JDK matches and Gradle has no way to download one, because the foojay resolver plugin is not applied.

What this error means

The build fails with "No matching toolchains found for requested specification: {languageVersion=21, ...} for LINUX ..." and a hint about auto-provisioning or installing the JDK.

Gradle
> Could not resolve all dependencies for configuration ':app:...'.
   > No matching toolchains found for requested specification:
     {languageVersion=21, vendor=any, implementation=vendor-specific} for LINUX on x86_64.
     Some toolchain resolvers had provisioning failures ...

Common causes

The requested JDK is not installed on the runner

The toolchain block asks for a Java version the runner image does not provide, and nothing can supply it.

The foojay toolchain resolver is not applied

Without the foojay-resolver-convention plugin, Gradle has no download resolver, so it cannot auto-provision the missing JDK.

How to fix it

Install the JDK with setup-java

Provision the requested version so a matching toolchain is present on the runner.

.github/workflows/ci.yml
- uses: actions/setup-java@v4
  with:
    distribution: temurin
    java-version: '21'

Enable the foojay toolchain resolver

Apply the foojay-resolver-convention plugin so Gradle can download a matching JDK when none is installed.

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

How to prevent it

  • Install the requested JDK with setup-java in the job.
  • Apply the foojay-resolver-convention plugin for auto-provisioning.
  • Keep the toolchain language version aligned with an available JDK.

Frequently asked questions

What causes ""No matching toolchains found""?
The toolchain block asks for a Java version the runner image does not provide, and nothing can supply it.
How do I fix "No matching toolchains found"?
Provision the requested version so a matching toolchain is present on the runner.

Related guides

References

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