How to Fix “Execution failed for task ‘:app:compileDebugKotlin’” Error in Flutter
If you are building a Flutter Android app and suddenly see this error:
Execution failed for task ':app:compileDebugKotlin'
then your Flutter project is failing during the Android Kotlin compilation step.
This is one of the most common Flutter Android build errors. It usually appears when there is a mismatch between Flutter version, Kotlin version, Android Gradle Plugin, Gradle version, Java/JDK version, or plugin dependencies.
In this guide, we will fix the error step by step in a professional way.
Officially, Flutter requires a supported Kotlin version for Android builds, and Android Gradle Plugin compatibility also depends on Gradle and JDK versions. Flutter documentation notes that Kotlin 1.5.31 or greater is required for Android Flutter apps, while modern Android Gradle Plugin versions commonly require JDK 17.
What Does This Error Mean?
The error:
Execution failed for task ':app:compileDebugKotlin'
means Gradle tried to compile Kotlin files inside your Android project, but the compilation failed.
In Flutter, Android native code lives inside the android folder. Even if your main app is written in Dart, many Flutter plugins use Android Kotlin code internally.
So this error can happen because of:
- Old Kotlin version
- Wrong Gradle version
- Android Gradle Plugin mismatch
- JDK mismatch
- Corrupted Gradle cache
- Plugin dependency conflict
- compileSdkVersion issue
- Android Studio using the wrong JDK
- Outdated Flutter project structure
Read : How to Fix “Gradle Build Failed” Error in Flutter (Complete Guide 2026)
Common Error Example
You may see something like this:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
Or:
Could not determine the dependencies of task ':app:compileDebugKotlin'
Or:
Kotlin could not find the required JDK tools in the Java installation
Or:
Module was compiled with an incompatible version of Kotlin
Quick Fix First
Before changing versions, run these commands:
flutter clean
flutter pub get
cd android
./gradlew clean
cd ..
flutter run
On Windows PowerShell:
flutter clean
flutter pub get
cd android
.\gradlew clean
cd ..
flutter run
If this fixes the issue, the problem was probably caused by temporary Gradle or Flutter build cache.
If the error still appears, follow the complete solutions below.
Solution 1: Check Your Flutter Version
Run:
flutter --version
If you are using FVM, run:
fvm flutter --version
Then check your project Flutter version:
fvm list
If your project uses FVM, always run commands like this:
fvm flutter clean
fvm flutter pub get
fvm flutter run
Do not mix normal Flutter and FVM Flutter in the same project.
Read : Flutter FVM – Complete Guide to FVM (Flutter Version Management)
Solution 2: Update Kotlin Version
One of the most common reasons for this error is an outdated Kotlin Gradle plugin.
Open:
android/settings.gradle
You may see something like this:
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.6.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.24" apply false
}
Update Kotlin to a compatible version.
Example:
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.6.0" apply false
id "org.jetbrains.kotlin.android" version "2.0.21" apply false
}
For many Flutter projects, Kotlin 1.9.24 or 2.0.21 is stable depending on your Gradle and Android Gradle Plugin version.
Kotlin’s official Gradle documentation explains that Kotlin, Gradle, and Android Gradle Plugin compatibility must be checked together, not independently.
Solution 3: Update Android Gradle Plugin
Open:
android/settings.gradle
Find:
id "com.android.application" version "8.x.x" apply false
Use a compatible Android Gradle Plugin version.
Example:
id "com.android.application" version "8.6.1" apply false
Do not blindly use the latest AGP version if your Flutter version does not support it properly.
For most stable Flutter projects, AGP 8.x is safer than jumping directly to AGP 9.x.
Android’s official release notes show that AGP versions have strict compatibility requirements for Gradle, SDK Build Tools, and JDK. For example, AGP 8.0 requires JDK 17, while newer AGP 9.x versions use Gradle 9.x and newer Android build tooling.
Solution 4: Update Gradle Wrapper
Open:
android/gradle/wrapper/gradle-wrapper.properties
You will see:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
Use a Gradle version compatible with your Android Gradle Plugin.
Example:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
A safe combination for many Flutter projects:
Android Gradle Plugin: 8.6.1
Gradle: 8.7
Kotlin: 1.9.24 or 2.0.21
JDK: 17
Solution 5: Use JDK 17
Modern Flutter Android builds generally require JDK 17, especially when using Android Gradle Plugin 8.x.
Check Java version:
java -version
Expected output should be similar to:
java version "17.x.x"
If you see Java 8, Java 11, or Java 21 and your project is not configured for it, change it to JDK 17.
In Android Studio:
File > Settings > Build, Execution, Deployment > Build Tools > Gradle
Set Gradle JDK to:
Embedded JDK 17
or your installed JDK 17 path.
Solution 6: Fix compileSdkVersion
Open:
android/app/build.gradle
Check:
android {
namespace "com.example.app"
compileSdk 35
}
If your dependencies require a newer SDK, update it:
android {
namespace "com.example.app"
compileSdk 36
}
Also check:
defaultConfig {
minSdk 23
targetSdk 36
}
Many Android plugins require a higher compile SDK. If compile SDK is too low, Gradle may fail during Kotlin or dependency compilation.
Read : How to change Android minSdkVersion in Flutter Project?
Solution 7: Delete Gradle Cache
Sometimes this error happens because Gradle cache is corrupted.
Close Android Studio and VS Code first.
Then delete these folders:
Windows
C:\Users\YourName\.gradle\caches
C:\Users\YourName\.gradle\daemon
Project-level:
your_project\android\.gradle
your_project\build
your_project\.dart_tool
Then run:
flutter clean
flutter pub get
flutter run
Solution 8: Update Flutter Dependencies
Run:
flutter pub outdated
Then update packages:
flutter pub upgrade
If you want major version updates:
flutter pub upgrade --major-versions
But be careful. Major updates can break existing code.
After updating:
flutter clean
flutter pub get
flutter run
Read : How to Upgrade Flutter SDK (Step by Step Guide for Developers)
Solution 9: Check Problematic Plugin
Sometimes the issue is caused by one Flutter plugin.
Run:
flutter run -v
Look carefully above the error. You may see a plugin name like:
firebase_messaging
google_maps_flutter
image_picker
permission_handler
Then update that plugin in pubspec.yaml.
Example:
dependencies:
firebase_messaging: latest_version
permission_handler: latest_version
Then run:
flutter pub get
Solution 10: Fix Kotlin JVM Target
Open:
android/app/build.gradle
Add or update:
kotlinOptions {
jvmTarget = '17'
}
Example:
android {
namespace "com.example.app"
compileSdk 36
defaultConfig {
applicationId "com.example.app"
minSdk 23
targetSdk 36
versionCode 1
versionName "1.0"
}
kotlinOptions {
jvmTarget = '17'
}
}
If your project uses newer Gradle syntax, check the Kotlin compiler options according to your Kotlin version.
Solution 11: Fix Old Flutter Android Project Structure
Older Flutter projects may still have old Gradle files.
Old projects may use:
buildscript {
ext.kotlin_version = '1.7.10'
}
New Flutter projects usually use plugin versions inside:
android/settings.gradle
If your project is very old, create a new Flutter project and compare the android folder.
Run:
flutter create temp_project
Then compare:
temp_project/android/settings.gradle
temp_project/android/build.gradle
temp_project/android/app/build.gradle
Update your old project carefully.
Solution 12: Stop Gradle Daemon
Sometimes Gradle daemon gets stuck.
Run:
cd android
./gradlew --stop
./gradlew clean
cd ..
flutter run
On Windows:
cd android
.\gradlew --stop
.\gradlew clean
cd ..
flutter run
Solution 13: Remove Conflicting Build Files
Delete these folders from your Flutter project:
build
.dart_tool
android/.gradle
android/app/build
Then run:
flutter clean
flutter pub get
flutter run
This forces Flutter and Gradle to rebuild everything from scratch.
Solution 14: Check Android Studio SDK Setup
Open Android Studio:
Settings > Languages & Frameworks > Android SDK
Install:
Android SDK Platform 35 or 36
Android SDK Build-Tools
Android SDK Command-line Tools
Android Emulator
Android SDK Platform-Tools
Then run:
flutter doctor -v
Fix any issue shown by Flutter doctor.
Read : Flutter Doctor command — What is flutter doctor (2026 Complete Guide)
Recommended Working Configuration
For a modern Flutter project, this is a safe setup:
Flutter: Latest stable
Dart: bundled with Flutter
JDK: 17
Android Gradle Plugin: 8.x
Gradle: 8.x
Kotlin: 1.9.24 or 2.0.x
compileSdk: 35 or 36
minSdk: 23
targetSdk: 35 or 36
Avoid mixing very new AGP 9.x with older Flutter projects unless you know the compatibility clearly.
Final Working Commands
After applying fixes, run:
flutter clean
flutter pub get
cd android
./gradlew clean
cd ..
flutter run
For Windows:
flutter clean
flutter pub get
cd android
.\gradlew clean
cd ..
flutter run
For FVM users:
fvm flutter clean
fvm flutter pub get
cd android
.\gradlew clean
cd ..
fvm flutter run
Common Mistakes to Avoid
Do not do these things:
- Do not randomly update only Kotlin without checking Gradle.
- Do not use Java 8 with modern Android Gradle Plugin.
- Do not mix FVM Flutter and system Flutter.
- Do not keep old Gradle cache after changing versions.
- Do not update all dependencies blindly without testing.
- Do not use latest AGP 9.x in an old Flutter project without compatibility check.
Best Practical Fix Combination
If you want one practical solution, try this combination first:
JDK: 17
Kotlin: 1.9.24
Android Gradle Plugin: 8.6.1
Gradle: 8.7
compileSdk: 35 or 36
Then run:
flutter clean
flutter pub get
cd android
./gradlew clean
cd ..
flutter run
This fixes the error in most Flutter Android projects.
Read : Android Studio Download and Android SDK Setup steps for Flutter Development
Conclusion
The error:
Execution failed for task ':app:compileDebugKotlin'
is usually caused by version mismatch or corrupted build cache in Flutter Android projects.
The best way to fix it is:
flutter clean
flutter pub get
Then check:
Kotlin version
Android Gradle Plugin version
Gradle wrapper version
JDK version
compileSdkVersion
Flutter plugins
For most modern Flutter projects, using JDK 17, compatible Kotlin, AGP 8.x, and clean Gradle cache will solve the issue.
FAQ for (Execution Failed for Task app:compileDebugKotlin)
It happens when the Android Kotlin compiler fails. The reason can be Kotlin version mismatch, Gradle mismatch, wrong JDK, corrupted cache, or outdated Flutter plugins.
It is mainly an Android build error inside a Flutter project. Flutter uses Gradle to build Android apps, and Gradle uses Kotlin compiler for Kotlin-based plugins and Android code.
Yes, sometimes. If the issue is caused by temporary build cache, flutter clean can fix it. But if the problem is version mismatch, you must update Kotlin, Gradle, AGP, or JDK.
For modern Flutter Android builds, use JDK 17. Android Gradle Plugin 8.x requires JDK 17.
Not always. You should use a Kotlin version compatible with your Android Gradle Plugin and Gradle version. Kotlin’s Gradle documentation recommends checking compatibility between Kotlin, Gradle, and AGP together.
Firebase plugins often require updated Android build tools. If your Kotlin, Gradle, compileSdk, or AGP version is old, Firebase-related plugins can trigger this error.
Yes. If Gradle cache is corrupted, deleting .gradle/caches, project build, and android/.gradle can fix the issue.
Keywords
- Execution failed for task app compileDebugKotlin Flutter,
- Flutter compileDebugKotlin error,
- fix compileDebugKotlin Flutter,
- Flutter Kotlin build failed,
- Execution failed for task app compileDebugKotlin,
- Flutter Android Gradle error,
- Flutter Kotlin Gradle error,
- Flutter build failed compileDebugKotlin,
- compileDebugKotlin failed Flutter,
- Flutter Gradle Kotlin error fix