• 在 Android 开发中,出现如下错误信息
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'org.jetbrains.kotlin.android'.
   > [IncompatibleGradleVersionTooLowFatalError | FATAL] Gradle Version Incompatible with Kotlin Gradle Plugin
     Kotlin Gradle Plugin <-> Gradle compatibility issue:
     The applied Kotlin Gradle is not compatible with the used Gradle version (Gradle 7.4).
     Please update the Gradle version to at least Gradle 7.6.3.
问题原因
  1. Kotlin 插件和 Gradle 版本不兼容导致构建失败

  2. 当前环境是 Gradle 7.4,Kotlin 插件要求至少需要 Gradle 7.6.3

处理策略
  1. 升级 Gradle 版本
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
  1. 或者,在项目级 build.gradle 文件中,降级 Kotlin 插件版本
// Gradle 旧版写法

buildscript {
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0"
    }
}
// Gradle 新版写法

plugins {
    id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
}

更多推荐