你的项目需要更新版本的Kotlin Gradle插件错误。

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

your project requires a newer version of the kotlin gradle plugin error

问题

当我尝试构建应用程序时,它抛出错误 - 您的项目需要更新的 Kotlin Gradle 插件版本

[!] 您的项目需要更新的 Kotlin Gradle 插件版本。请在 https://kotlinlang.org/docs/gradle.html#plugin-and-versions 上查找最新版本,然后更新 E:\flutter_apps\geodata\android\build.gradle 文件中的以下部分:
ext.kotlin_version = '';

我已经按照以下方式升级了我的 android/build.gradle 文件。

buildscript {
    ext.kotlin_version = '1.7.20'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

以及我的 android/gradle/wrapper/gradle-wrapper.properties 文件如下:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip

请有人可以帮助我吗?

英文:

When I try to build app it throws error - your project requires a newer version of the kotlin gradle plugin.

 [!] Your project requires a newer version of the Kotlin Gradle plugin.                                                                            │
│ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, 
| then update E:\flutter_apps\geodata\android\build.gradle: │
│ ext.kotlin_version = '<latest-version>'

I have already upgrade my android/build.gradle as below.

buildscript {
    ext.kotlin_version = '1.7.20'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And my android/gradle/wrapper/gradle-wrapper.properties as below

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip

Please any one can help me?

答案1

得分: 5

I had the same issue. and I tried multiple solutions. none worked.
finally got the solution.
copy and paste the below code in android/build.gradle

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

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
    }
}

and also change distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip in android/gradle/wrapper/gradle-wrapper.properties

英文:

I had the same issue. and I tried multiple solutions. none worked.
finally got the solution.
copy and past the below code in android/build.gradle

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

dependencies {
    classpath 'com.android.tools.build:gradle:7.2.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.10'

}

and also change distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip in android/gradle/wrapper/gradle-wrapper.properties

答案2

得分: 2

I had the same issue when I updated to Flutter 3.13.3 which requires higher Kotlin version, and you can find latest Kotlin version here Kotlin Releases.
then go to android/build.gradle and edit Kotlin Version as following:


buildscript {
    ext.kotlin_version = "1.9.10" //Update with the latest version
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

英文:

I had the same issue when I updated to Flutter 3.13.3 which requires higher Kotlin version, and you can find latest Kotlin version here Kotlin Releases.
then go to android/build.gradle and edit Kotlin Version as following:


buildscript {
    ext.kotlin_version = "1.9.10" //Update with the latest version
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

答案3

得分: 0

在我的情况下,这是由之前的错误引起的:

SigningConfig "release" 缺少所需的属性 'storeFile'

在我更新 android/app/build.gradle 文件,添加了 storeFile,以及 ./android/key.properties 文件后,

这个 "kotlin 的新版本" 错误就不再出现了。

这是在我的情况下出现的错误消息不正确。

英文:

In my case, it was caused by a previous error:

SigningConfig "release" is missing required property 'storeFile'

After I update android/app/build.gradle, with storeFile, and ./android/key.properties file

This "newer version of the kotlin" error just go away.

It's a wrong error message in my case.

huangapple
  • 本文由 发表于 2023年2月10日 15:26:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/75408051.html
匿名

发表评论

匿名网友

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

确定