我已将
geolocator
插件添加到我的 flutter 应用程序中,但它出错并告诉我 Your project requires a newer version of the Kotlin Gradle plugin.
我刚刚创建了这个项目,因此正在使用最新版本的 flutter,以及所有 android build.gradle
更改。我正在使用 geolocator: ^12.0.0
,我尝试在 ext.kotlin_version = '2.0.0'
中设置 android>build.gradle
但结果是相同的,无论我是否明确设置了版本
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
}
完全错误
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
如果您使用的是最新的 flutter 版本,请进行以下更改
从
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
}
}
那么,
更新
settings.gradle
中的kotlin版本