Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Gradle cannot find the kotlin-dsl plugin in buildSrc or an included build

Errororg.gradle.kotlin.kotlin-dsl was not found

Short answer

The kotlin-dsl plugin is resolved like any other plugin, from the repositories in pluginManagement. If settings.gradle(.kts) lists only google() or leaves out gradlePluginPortal(), or the plugin line carries a version that does not match your Gradle, resolution fails. Fix the repositories, and apply the plugin with the kotlin-dsl accessor.

  • Applies to Gradle 8.x, Gradle 9.x, Kotlin DSL
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open the file that applies the plugin (usually buildSrc/build.gradle.kts or the build-logic one) and the settings file of that build. Note the plugin line and the pluginManagement repositories.

    cat buildSrc/build.gradle.kts
    cat settings.gradle.kts
  2. 2Match what you see, then jump to its fix

    1. 1settings.gradle(.kts) has a pluginManagement repositories block without gradlePluginPortal()pluginManagement leaves out the Gradle Plugin PortalFix
    2. 2The plugin line carries an explicit versionThe plugin is declared with a version that does not belong to this GradleFix

What does the error look like?

  • org.gradle.kotlin.kotlin-dsl was not found

Cause 1 of 2

pluginManagement leaves out the Gradle Plugin Portal

1Check

Gradle's plugin docs say plugins resolve from the Gradle Plugin Portal by default, and that a repositories block inside pluginManagement replaces that, so the portal is searched only if you list it.

grep -n -A8 "pluginManagement" settings.gradle settings.gradle.kts

2Fix

Add gradlePluginPortal() to pluginManagement.repositories in the settings file of the build that applies the plugin.

// settings.gradle.kts
pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}

3Verify

Run any task of the build; the plugin resolves.

./gradlew help

Confirmed by docs.gradle.org

Did this fix it?

Cause 2 of 2

The plugin is declared with a version that does not belong to this Gradle

1Check

Gradle's Kotlin DSL docs say each Gradle release is meant to be used with a specific version of the kotlin-dsl plugin, and that an unexpected version causes warnings and hard-to-diagnose problems.

./gradlew --version
grep -rn "kotlin-dsl" --include=*.kts --include=*.gradle .

2Fix

Use the kotlin-dsl accessor with no version, and add a repository for the Kotlin compiler dependencies, as the docs show for buildSrc.

// buildSrc/build.gradle.kts
plugins {
    `kotlin-dsl`
}

repositories {
    mavenCentral()
}

3Verify

Build again. The plugin now matches the running Gradle.

./gradlew help

Confirmed by docs.gradle.org

Did this fix it?

How do I stop it coming back?

  • Keep pluginManagement repositories in one settings file and copy them to each included build that needs them.
  • Do not pin a version on kotlin-dsl; let the Gradle version decide.
  • After raising Gradle, check the compatibility table for the embedded Kotlin version.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.