┌─ Flutter Fix ──────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then │
│ update /Users/a1234/Desktop/test0717/ttt/android/build.gradle: │
│ ext.kotlin_version = '<latest-version>' │
└────────────────────────────────────────────────────────────────────────────────────────────┘
flutter开发爬坑记录:
e: /Users/a1234/.pub-cache/hosted/pub.dev/nordic_dfu-6.1.4+hotfix/android/src/main/kotlin/dev/steenbakker/nordicdfu/ResourceUtils.kt: (71, 21): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
The class is loaded from /Users/a1234/.gradle/caches/transforms-3/fcc4b519de205b6648feccd3aff6677d/transformed/jetified-kotlin-stdlib-1.9.23.jar!/kotlin/Unit.class
核心问题就就是:这句话:The binary version of its metadata is 1.9.0, expected version is 1.7.1.(其元数据的二进制版本为1.9.0,预期版本为1.7.1)。
在网上找了很多方法,按照他们说的做了之后,由于本人愚钝还是不行。
最终,老天爷保佑,让我找到了解决方法。
其实也很简单:根据报错信息提到的1.90和1.7.1在整个项目全局搜索‘1.7.1’这个词,最终找到
在settings.gradle文件里找到这行代码: id "org.jetbrains.kotlin.android" version "1.7.10" apply false。把这行代码里的1.7.10改成1.9.0。然后运行,大功告成,原来如此简单。
值得注意的是,运行过程中网络必须通畅,最好有个网速不错的科学上网方式,否则经常下载失败。