Flutter Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0

huangapple go评论53阅读模式
英文:

Flutter Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0

问题

在Flutter中出现**模块与不兼容的Kotlin版本编译。其元数据的二进制版本为1.8.0,预期版本为1.6.0。**的问题。

在格式化系统安装的Android Studio之后 - Chipmunk | 2021.2.1 Patch 2
Kotlin版本 - 212-1.6.10-release-923-AS5457.46

Flutter版本3.7.3和Dart版本2.19.2

已尝试以下解决方法:

  • 清除缓存
  • 清理Gradle文件
  • 在Android Studio中,您可以转到“Build” -> “Clean Project”
  • 运行命令flutter cleanflutter pub get
  • 从系统重新格式化并重新安装

详细的逐步解决问题的方法:

  1. 确保Android Studio和Flutter的版本都是最新的。

  2. 在项目目录中,打开终端并运行以下命令以清除Flutter的构建缓存:

    flutter clean
    
  3. 在项目目录中,运行以下命令以获取依赖项:

    flutter pub get
    
  4. 在Android Studio中,点击菜单中的 "File" -> "Invalidate Caches / Restart",然后选择 "Invalidate and Restart" 来清除缓存并重启Android Studio。

  5. 检查项目的build.gradle文件,确保Kotlin版本与Android Studio的版本兼容。您可以在build.gradle文件中找到Kotlin版本的设置。

  6. 如果仍然遇到问题,请尝试升级或降级Kotlin版本,以确保与Flutter兼容。您可以在项目的build.gradle文件中进行相应的更改。

  7. 如果上述步骤仍未解决问题,考虑卸载并重新安装Android Studio,并确保安装了与您项目兼容的Kotlin版本。

希望这些步骤可以帮助您解决Kotlin版本不兼容的问题。如果问题仍然存在,请提供更多详细信息,以便更好地帮助您解决问题。

英文:

In flutter getting ** Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.**

After formatting the system installed Android Studio - Chipmunk | 2021.2.1 Patch 2
Kotlin version - 212-1.6.10-release-923-AS5457.46

Flutter version 3.7.3 and Dart version 2.19.2

Have tried

  • Invalidating cache
  • Cleaning gradle files
  • In Android Studio, you can go to Build -> Clean Project
  • flutter clean, flutter pub get
  • Have also formatted the OS from the system and reinstalled

[✓] Flutter (Channel stable, 3.7.3, on macOS 12.6.6 21G646 darwin-x64, locale
    en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.78.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

Detailed Step by step answer to resolve the issue

答案1

得分: 2

我们面临了相同的问题,我们的项目停滞了整整一周,

根本原因分析(RCA):

这个问题是因为我们在Flutter包版本前面添加的 ^ 符号引起的。这导致了pubspec.lock文件被修改为包的最新版本。

解决方案:

我们将版本中的 ^ 符号删除,并按照以下步骤进行操作:

  1. 运行命令:flutter pub cache clean
  2. 删除 pubspec.lock 文件
  3. 运行命令:flutter pub get

这样做会重新生成 pubspec.lock 文件,并包含在 pubspec.yaml 中指定的确切版本的包。

英文:

We faced the same issue and our project was at a stand still for a whole week,

RCA:

The issue was caused because of the ^ we add in front of the flutter package versions. Due to which the pubspec.lock got modified with a latest version of the packages.

Solution:

We removed the ^ from the versions and followed below steps

  1. flutter pub cache clean
  2. delete pubspec.lock
  3. flutter pub get

this resulted in the pubspec.lock being generated again with the exact versions of the packages mentioned in the pubspec.yaml

答案2

得分: 0

android/build.gradle中的kotlin版本更改为1.6.0或更高版本。

kotlin版本链接:https://docs.flutter.dev/release/breaking-changes/kotlin-version

buildscript {
    ext.kotlin_version = '1.7.10' // 更新kotlin版本
    repositories {
        google()
        jcenter()
    }
}
英文:

Change kotlin version to 1.6.0 or above in android/build.gradle.

kotlin-version https://docs.flutter.dev/release/breaking-changes/kotlin-version

buildscript {
    ext.kotlin_version = '1.7.10' // update kotlin version
    repositories {
        google()
        jcenter()
    }

huangapple
  • 本文由 发表于 2023年5月29日 12:37:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76354706.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定