我的项目需要更新版本的 Kotlin Gradle 插件,但建议的修复方法不起作用

My project requires a newer version of the Kotlin Gradle plugin, but the suggested fix doesn't work

所以我刚升级了flutter,很快就报错了:

┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────┐
│ [!] 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\myUsername\Desktop\Swiper\Swiper-main\android\build.gradle:                  │
│ ext.kotlin_version = '<latest-version>'                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

这是升级时的known breaking change

我应用了建议的修复,但错误并没有消失

这是我的 \android\build.gradle:

buildscript {
    ext.kotlin_version = '1.6.10' //there was nothing here before
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath 'com.google.gms:google-services:4.3.5'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}
(...)

我尝试过的事情:

-扑干净

-重启 VS Code

-关闭并再次冷启动模拟器。

-查看相似主题

-将实现“org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10”添加到我的 app/build.gradle

-在 Android Studio 中打开 /android 并尝试 Gradle 同步(Gradle 同步失败:同步失败: 原因未知(1 米 26 秒 622 毫秒))

试试这个

 dependencies {
        classpath 'com.android.tools.build:gradle:7.0.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
    
    }

然后转到 android>gradle>包装器>gradle-wrapper.properties 文件 更改 zip 文件版本

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

change the kotlin version in build.gradle from XXX to 1.6.10 or to newer version

build.gradle>gradle>android