ext.kotlin_version = <'latest version'> error on Flutter

Viewed 17367

I am trying to place advertising in my flutter app, this is proving to be almost more complicated for me than creating the app itself (I am a newbie dev starting with flutter).

I get an error when I try to launch my app that says the following: [!] Your project requires a newer version of the Kotlin Gradle plugin. Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update C:\Users\User\Desktop\Dev\adtest\android\build.gradle: ext.kotlin_version = '' Exception: Gradle task assembleDebug failed with exit code 1

The problem seems simple, I have to update the field suggested by the console. My surprise is that the field ext.kotlin_version = " ", does not exist in my build.grade file on android/build.gradle. Neither does the buildscript { } apatagate exist that should contain it. I have android Studio installed, Flutter updated, I work with visual studio code, everything is apparently correct, except for this.

Thanks for your help.

7 Answers

Add ext.kotlin_version and kotlin dependency in <app>/android/build.gradle file.

buildscript {
    ext.kotlin_version = '1.5.0' //use latest
    ...
}

dependencies { 
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    ...
}

Copy and paste. ext.kotlin_version = '1.4.32' On location: android/

Update kotlin version to '1.4.32'.

Copy and paste ext.kotlin_version = '1.4.32' On Project-level build.gradle(/build.gradle)

Official Website link for getting latest version you can see <project_name>/android/build.gradle

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

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

}

You can find here

Step 1: Open your project on android studio and go to Tools->kotlin->"Configure kotlin plugin updates", update and ensure you apply changes.

Step 2: navigate to your flutter project_folderName/android/build.grade file and change

buildscript {

ext.kotlin_version = 'the version you updated to'

}

step 3: build and debug your project.

I was facing the same error and resolved it by this method. I hope this will also for you. Just follow these steps

  • open your terminal
  • run -> dart pub outdated (it will show you all outdated versions of the project)
  • run -> dart pub upgrade --major-versions
  • restart your android studio
Related