Flutter: Execution failed for task ':app:compileDebugKotlin'

AndroidFlutterDartDebugging

Android Problem Overview


I tried running the default flutter app from flutter create on my android device but it throws me an error. Can someone help?

> Launching lib\main.dart on SM G610F in debug mode... Running Gradle > task 'assembleDebug'... > > FAILURE: Build failed with an exception. > > * What went wrong: Execution failed for task ':app:compileDebugKotlin'. > > Could not resolve all artifacts for configuration ':app:debugCompileClasspath'. . . . > > * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. > > * Get more help at https://help.gradle.org > > BUILD FAILED in 14s Finished with error: Gradle task assembleDebug > failed with exit code 1

This is my flutter doctor:

> [√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows > [Version 10.0.10586], locale en-US) > • Flutter version 1.12.13+hotfix.5 at E:\flutter\flutter > • Framework revision 27321ebbad (6 weeks ago), 2019-12-10 18:15:01 -0800 > • Engine revision 2994f7e1e6 > • Dart version 2.7.0 > > [√] Android toolchain - develop for Android devices (Android SDK > version 29.0.2) > • Android SDK at C:\Users\208046\AppData\Local\Android\sdk > • Android NDK location not configured (optional; useful for native profiling support) > • Platform android-29, build-tools 29.0.2 > • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java > • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03) > • All Android licenses accepted. > > [√] Android Studio (version 3.5) > • Android Studio at C:\Program Files\Android\Android Studio > • Flutter plugin version 42.1.1 > • Dart plugin version 191.8593 > • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03) > > [√] VS Code, 64-bit edition (version 1.41.1) > • VS Code at C:\Program Files\Microsoft VS Code > • Flutter extension version 3.7.1 > > [√] Connected device (1 available) > • SM G610F • 33005566b2b5c3df • android-arm • Android 8.1.0 (API 27) > > • No issues found!

edit: for my complete logs you can see here:

Flutter github issues

Android Solutions


Solution 1 - Android

Go to your build.gradle file in the root of your Android directory and upgrade your Kotlin_version to the latest. As of the time of typing this, the latest is 1.5.10, so it should look like this:

ext.kotlin_version = '1.5.10'

Solution 2 - Android

Solved the problem by deleting android/.gradle then ran the app in debug

Solution 3 - Android

A possible fix can be upgrading the project/android/build.gradle Steps to fix,

  1. flutter clean
  2. Delete android/.gradle
  3. Go to android/build.gradle, upgrade ext.kotlin_version to latest. In my case(1.3.0 -> 1.5.10), ext.kotlin_version = '1.5.10'

After doing this as well, I was getting A problem occurred evaluating project ':app'. > Failed to apply plugin [id 'kotlin-android'] > The current Gradle version 5.6.2 is not compatible with the Kotlin Gradle plugin. Please use Gradle 6.1 or newer, or the previous version of the Kotlin plugin.

To fix this,

  1. Go to android/gradle/wrapper/gradle-wrapper.properties
  2. Update the distributionUrl to the latest version.In my case((5.6.2 -> 6.1.1) it is, distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

Solution 4 - Android

For me, I found that when building that 2 different MainActivity.kt files were in andriod/app/src/main/kotlin. One had a default MainActivity.kt file with the package name that was originally generated for my project. Something like 'example.project_name' . The other one had what I changed my project name into. I went ahead and deleted the folder with the MainActivity.kt containing the import starting with 'example.project_name' and that resolved the issue for me.

Solution 5 - Android

in android folder of your project run in terminal

gradlew clean

Then build. This worked for me.

Solution 6 - Android

It was fixed after I upgraded my build.gradle file ext.kotlin_version = '1.5.10'

First of all run

flutter clean
flutter pub get

Go to andriod/build.gradle then upgrade ext.kotlin_version

buildscript {
    ext.kotlin_version = '1.5.10'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
} 

Solution 7 - Android

I solved it. It was because of my network blocked non secured http download request. I changed my network and the gradle build completed itself.

Solution 8 - Android

I Solved it by upgrading kotlin version in root build.gradle file:

ext.kotlin_version = '1.5.10'

Solution 9 - Android

First of make sure that you have latest version of flutter. For confirmation, please run flutter upgrade in command prompt / terminal:

flutter upgrade

Then visit the site Click Here and copy the new latest version of kotlin. For now: in March 02, 2022 current kotlin version is 1.6.10

Then after it:

-> Go to android/build.gradle
-> change to ext.kotlin_version = '1.6.10'

Click here to view Screenshot example

Solution 10 - Android

It was fixed after I upgraded my Flutter by running flutter upgrade

Solution 11 - Android

I have been facing this issue for couple of hours. At the end right now my issue solved by executing following steps -

- change Settings -> Build, Execution, Development -> Compiler -> Kotlin Compiler -> Kotlin to JVM -> check Enable incremental comilation -> Target JVM version 1.6 to 1.8

- add to build.gradle under repositories in both buildscript and allprojects section

maven {
        url 'http://download.flutter.io'
    }

-and lastly run on command line 'flutter pub cache repair'

enter image description here

Solution 12 - Android

I got the problem after migrating to null-safety. I fixed it by updating the kotlin version in the file android\build.gradle

ext.kotlin_version = '1.3.50'

Then run 'flutter clean' and the app worked fine.

Solution 13 - Android

> Just increase the ext.kotlin.version from whatever version you have, to '1.4.32' or whatever the latest version is available kotline version

Solution 14 - Android

when I ran flutter upgrade in the command line prompt it was fixed and ran my app .. try it

Solution 15 - Android

Faced the same issue: Execution failed for task ':app:compileDebugKotlin'. Execution failed for task ':app:compileDebugKotlin'.

solution: Changed the company domain with only one dot. solution

Solution 16 - Android

I was using JRE for Java. I just install the AdoptOpenJDK 11 and it works

Solution 17 - Android

I encountred the same problem and tried all the solutions proposed here in this post ... and still not working.

but only after upgrading the packages in pubspec.yaml with:

flutter pub upgrade

it worked !!

Solution 18 - Android

For me, my package name imported twice automatically in MainActivity file under app>main>kotlin directory. I just delete duplicates and it works fine now!

Solution 19 - Android

Update to the latest version in my case it is 1.6.10 or create dummy project and check android/build.gradle and update.

ext.kotlin_version = '1.6.10'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSerpentariusView Question on Stackoverflow
Solution 1 - AndroidIlo CalistusView Answer on Stackoverflow
Solution 2 - AndroidtheeommView Answer on Stackoverflow
Solution 3 - AndroidBalaji VenkatramanView Answer on Stackoverflow
Solution 4 - AndroidPatrickView Answer on Stackoverflow
Solution 5 - AndroidTushar GautamView Answer on Stackoverflow
Solution 6 - AndroidMehedi HasanView Answer on Stackoverflow
Solution 7 - AndroidSerpentariusView Answer on Stackoverflow
Solution 8 - AndroidAMR SAMYView Answer on Stackoverflow
Solution 9 - AndroidMuhammad AliView Answer on Stackoverflow
Solution 10 - AndroidKoleen BPView Answer on Stackoverflow
Solution 11 - AndroidMimu Saha TishanView Answer on Stackoverflow
Solution 12 - AndroidHyung Tae Carapeto FigurView Answer on Stackoverflow
Solution 13 - Androidgautam singhView Answer on Stackoverflow
Solution 14 - AndroidHussam Hassan El-razzazView Answer on Stackoverflow
Solution 15 - AndroidAbdul AgfarView Answer on Stackoverflow
Solution 16 - AndroidPierre MonierView Answer on Stackoverflow
Solution 17 - AndroidAcePView Answer on Stackoverflow
Solution 18 - AndroidAl MamunView Answer on Stackoverflow
Solution 19 - Androiduser8819119View Answer on Stackoverflow