Maaz Zindani

Loading the index…

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

Gradle cannot find KotlinCompile.getDestinationDir() during the build

ErrorUnable to find method 'java.io.File org.jetbrains.kotlin.gradle.tasks.KotlinCompile.getDestinationDir()'

Short answer

This is a version mismatch, not a code bug. The Kotlin Gradle plugin, Gradle and the Android Gradle plugin must sit inside the compatibility ranges that Kotlin publishes. Find the Kotlin plugin row that covers your Gradle and AGP versions, then upgrade the plugin or the tools until all three fit one row.

  • Applies to Kotlin Gradle plugin 1.8 to 2.2, Gradle 7.6 to 8.14, Android Gradle Plugin 7.x to 8.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Write down the three versions in play: the Kotlin plugin, Gradle and the Android Gradle plugin. Then compare them with the compatibility table in the Kotlin documentation.

    ./gradlew --version
    grep -rn "org.jetbrains.kotlin\|com.android.application" --include=*.gradle --include=*.kts --include=*.toml .
  2. 2Match what you see, then jump to its fix

    1. 1The build broke after upgrading Gradle or the wrapper, and the Kotlin plugin version did not changeThe Kotlin Gradle plugin is too old for the Gradle versionFix
    2. 2AGP was upgraded (or Android Studio updated the project), and the Kotlin plugin stayed behindThe Android Gradle Plugin is outside the range of the Kotlin pluginFix

What does the error look like?

  • Unable to find method 'java.io.File org.jetbrains.kotlin.gradle.tasks.KotlinCompile.getDestinationDir()'

Cause 1 of 2

The Kotlin Gradle plugin is too old for the Gradle version

1Check

Kotlin publishes a minimum and maximum Gradle version for every plugin release. For example, plugin 1.8.0 to 1.8.11 is listed for Gradle 6.8.3 to 7.3.3, and 1.9.20 to 1.9.25 for 6.8.3 to 8.1.1. A Gradle version outside the range of your plugin is not supported.

./gradlew --version | grep Gradle

2Fix

Raise the Kotlin plugin to a release whose Gradle range includes your Gradle, for example 2.2.0 to 2.2.10 for Gradle 8.14, then rebuild.

// gradle/libs.versions.toml
kotlin = "2.1.21"
// or settings/plugins block
// id("org.jetbrains.kotlin.android") version "2.1.21" apply false

3Verify

Run the build; the method error is gone.

./gradlew clean assembleDebug

Confirmed by kotlinlang.org

Did this fix it?

Cause 2 of 2

The Android Gradle Plugin is outside the range of the Kotlin plugin

1Check

The same table lists an AGP range for each Kotlin plugin release; 1.9.20 to 1.9.25 covers AGP 4.2.2 to 8.1.0, and 2.1.0 to 2.1.10 covers 7.3.1 to 8.7.2.

grep -rn "com.android.application" --include=*.gradle --include=*.kts --include=*.toml .

2Fix

Choose the Kotlin release whose row includes both your Gradle and your AGP version, or move AGP down to that row. Newer versions than the table's maximum may work, but they are not guaranteed.

// pick one row, for example Kotlin 2.1.21 with AGP 8.7.2 and Gradle 8.12.1

3Verify

Sync and build again after aligning the versions.

./gradlew clean assembleDebug

Confirmed by kotlinlang.org

Did this fix it?

How do I stop it coming back?

  • Upgrade Kotlin, AGP and Gradle together, and check the Kotlin compatibility table first.
  • Keep all three versions in one place (a version catalog) so a mismatch is visible in review.
  • Run clean assembleDebug in CI after any version bump.

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.