Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter version 3.19.2 requires a newer version of the Kotlin Gradle plugin. /android/build.gradle: ext.kotlin_version = '<latest-version>'

I have a question about Flutter version 3.19.2. In this version, Flutter has removed the buildscript from the /android/build.gradle file:

allprojects {
    
    repositories {
        google()
        mavenCentral()
    }
        
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

Now, I'm wondering where to put the latest version of Kotlin. Could someone please guide me on the appropriate location for specifying the Kotlin version in this updated configuration?

Thank you in advance!

I have attempted to search for information on the Flutter documentation website under Breaking Changes, but I couldn't find anything related to this particular issue.

like image 564
SalmanNaghori Avatar asked Dec 19 '25 15:12

SalmanNaghori


2 Answers

kotlin plugin version is shifted to settings.gradle in newer version of flutter. you can find kotlin plugin version in settings.gradle inside plugins tag

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "{agpVersion}" apply false
    id "org.jetbrains.kotlin.android" version "{kotlinVersion}" apply false
}

Answering @Taili:

When you upgrade flutter to 3.19.0 and run the application on android you will get a warning message about gradle plugin deprecation and also will get a link to the documentation how to fix it there you wil find files that needs to be change and when you create a new project that will you use the newer version of gradle plugins. the documentation provided there was little bit confusing for me for the first time and i made a lot mistakes following it and ended up messing the project badly. i asked a question on the stack overflow here is the link where you will find some useful tips and tricks how to change the project easily to newer version.

like image 57
Munsif Ali Avatar answered Dec 22 '25 10:12

Munsif Ali


I did the following steps - Worked for me

  1. Change the Kotlin version to the latest version, in android/settings.gradle file

In my case, it was 1.9.0 :

id "org.jetbrains.kotlin.android" version "1.9.0" apply false
  1. Run --> flutter clean

  2. get into the Android folder and run --> ./gradlew cleanBuildCache

  3. Go to %USERPROFILE%/.gradle and delete the --> caches folder.

  4. Run the Flutter app using the play-icon button

NOTE: If the .gradle/caches dosent get deleted then

  1. Press Windows + R and type --> resmon
  2. Under Associated Handles, search --> gradle
  3. End the java.exe process with gradle/caches in its path.
like image 32
SwasthikaDev Avatar answered Dec 22 '25 12:12

SwasthikaDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!