Flutter 版本 3.19.2 需要更新版本的 Kotlin Gradle 插件。 /android/build.gradle: ext.kotlin_version = '<latest-version>'

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

我有关于 Flutter 3.19.2 版本的问题。在此版本中,Flutter 已从

/android/build.gradle
文件中删除了构建脚本:

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 放在哪里。有人可以指导我在更新的配置中指定 Kotlin 版本的适当位置吗?

提前谢谢您!

我尝试在 Flutter 文档网站的 Breaking Changes 下搜索信息,但找不到与此特定问题相关的任何信息。

flutter kotlin version
2个回答
0
投票

Flutter版本3.19.2更新后。在此版本中,Flutter 已从

中删除了构建脚本
 /android/build.gradle

现在您可以在 settings.gradle 中添加最新版本的 Kotlin

/android/setting.gradle

这是我的setting.gradle文件:

pluginManagement {
def flutterSdkPath = {
    def properties = new Properties()
    file("local.properties").withInputStream { properties.load(it) }
    def flutterSdkPath = properties.getProperty("flutter.sdk")
    assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
    return flutterSdkPath
}
settings.ext.flutterSdkPath = flutterSdkPath()

includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

repositories {
    google()
    mavenCentral()
    gradlePluginPortal()
}
}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.2" apply false
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
id "com.google.gms.google-services" version "4.4.0" apply false
}

include ":app"

0
投票

在较新版本的 flutter 中,kotlin 插件版本已转移至 settings.gradle。 您可以在

settings.gradle
标签内的
plugins
找到 kotlin 插件版本

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
}
© www.soinside.com 2019 - 2024. All rights reserved.