新flutter项目中的Kotlin版本问题

问题描述 投票:0回答:1

我创建了一个新项目。当我添加

flutter_nfc_kit:
时,它会给出错误:

Your project requires a newer version of the Kotlin Gradle plugin.  

但是当我打开android级别的build.gradle文件时,它没有kotlin版本。当我尝试手动添加 kotlin 最新版本时,问题无法解决。添加 kotlin 版本后我的 build.gradle 是:

    buildscript {
    ext.kotlin_version = '2.0.0' 
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0"
        classpath 'com.google.gms:google-services:4.3.10'
    }
}

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
}

请大家就这个问题提出建议。它仅出现在新项目中,并且默认始终采用 kotlin 版本 1.7.1

android flutter flutter-dependencies nfc
1个回答
0
投票

我发现从Flutter 3.16版本开始,之前在build.gradle文件中的一些配置已经被移到了settings.gradle文件中。为了解决这个问题,我在settings.gradle文件中将Kotlin版本从1.7更新到2.0.0,这解决了问题。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.