flutter kotlin 依赖错误

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

我在应用程序运行时遇到大量这些错误,并且我一直在网上查看建议的解决方案,但效果不佳。似乎什么都不起作用。所以,错误:

e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: C:/Users/User/.gradle/caches/transforms-3/9508325ccc4e6492ee61ca313dfda75b/transformed/jetified-kotlin-stdlib-common-1.9.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.

我尝试过的:

我的 android pp uild.gradle 文件中最初缺少这整个部分,因此必须在插件 {} 之前将这整个部分添加到最顶部:

buildscript {
    ext.kotlin_version = '1.9.0'
    repositories {
        google()
        mavenCentral()
    }
}

我在那里尝试了 1.7.1,因为我认为错误表明了这一点,但它没有什么区别,就像它根本不识别这个设置一样。

我已尝试更新所有插件。

不知道我还应该用这个做什么,我相信我已经完全按照它要求我做的事情做了。

flutter kotlin
1个回答
0
投票

在较新版本的 android studio 中,当您创建新的 flutter 项目时,一些

build.gradle
(android/build.gradle) 代码已移至
settings.gradle
(android/settings.gradle)

要解决上述问题,请进行更改

setting.gradle

在插件中你将有以下几行:

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
}

您的“com.android.application”和“org.jetbrains.kotlin.android”可能有不同的版本,请将其更改为上述版本或最新版本

注意:如果您在

android/build.gradle
中添加了任何新内容,请删除 kodling 的这些更改

© www.soinside.com 2019 - 2024. All rights reserved.