I’ve added the geolocator
plugin to my flutter app, but it errors out and tells me Your project requires a newer version of the Kotlin Gradle plugin.
I’ve just created this project, so am using the latest version of flutter, with all the android build.gradle
changes. I’m using geolocator: ^12.0.0
, i’ve tried setting the ext.kotlin_version = '2.0.0'
in android>build.gradle
but the outcome is the same, whether I have explicitly set the version or not
android>build.gradle
buildscript {
ext.kotlin_version = '2.0.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2' // Use the latest version available
classpath 'com.google.gms:google-services:4.3.15' // Use the latest version available
}
}
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
}
Full error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileReleaseKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* 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 11s
Running Gradle task 'assembleRelease'... 11.8s
┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update │
│ /Users/user/Desktop/Folders/apps/app/android/build.gradle: │
│ ext.kotlin_version = '<latest-version>' │
└───────────────────────────────────────────────────────────────────────────────────────────────────┘
Gradle task assembleRelease failed with exit code 1
2
Answers
If you are using latest flutter version then make below changes
Remove below code from
build.gradle
}
Then,
Update the kotlin version in
settings.gradle
Click this Button will auto update this and check a logs it will take sometime