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

8

5

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?

Heaver answered 10/2, 2023 at 7:26 Comment(6)
Modify ext.kotlin_version = '1.8.10'Whipcord
I did this but it shows warning - Kotlin version that is used for building with Gradle (1.8.10) differs from the one bundled into the IDE plugin (1.7.20)Heaver
steel that error with -- ext.kotlin_version = '1.8.10'Heaver
Update your kotlin plugin in Android StudioWhipcord
in Android Studio latest kotlin version shows 1.8.0 - I updrage to 1.8.0 and set ext.kotlin_version = '1.8.0' then steel same problemHeaver
@DhavalChaudhari same here, mind if i ask what was your solution?Afflux
G
6

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

Gunsmith answered 23/4, 2023 at 4:3 Comment(0)
Q
4

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.

Quiberon answered 31/10, 2023 at 4:55 Comment(2)
Saved me, why is the wrong message tho. i lost almost 2 hours...Benignant
this saved me but if you go through the error it shows * What went wrong: Execution failed for task ':app:packageRelease'. > A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable > SigningConfig "release" is missing required property "storeFile". in my caseArse
K
0

I have just upgrade the kotlin version 1.6.10 to 1.7.10 and solved my issue

buildscript {
    ext.kotlin_version = "1.7.10" //just updated
    repositories {
        google()
        mavenCentral()
    }

}
Kyliekylila answered 15/12, 2023 at 10:43 Comment(0)
D
0

Go to the Flutter Project's build.gradle -

see this block - 

buildscript {
    ext.kotlin_version = '1.9.22' // replace with lastest version(below link) 
    repositories {
        google()
        mavenCentral()
    }
dependencies {
    classpath 'com.android.tools.build:gradle:7.3.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.4'
}


This is link - https://github.com/JetBrains/kotlin/releases/tag/v1.9.22

This is the link for latest version of Kotlin

Deen answered 9/2 at 13:31 Comment(0)
S
0

I tried all the solutions given in this thread but non worked. The issue was like there is no buildscript section in my build.gradle file. I tried adding the ones that are in this thread and still isnt working even after updating to 1.9.22 (the latest version).

This error message is showing up now. Error Message

Semiconductor answered 24/2 at 17:0 Comment(1)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewUnmuzzle
J
0

There are two steps to resolve this

  1. In android/app/build.gradle add ext.kotlin_version = 'YOUR_VERSION_HERE'

     buildscript {
     ext.kotlin_version = '2.0.0'
     repositories {
         google()
         mavenCentral()
     }
    
     dependencies {
         classpath "org.jetbrains.kotlin:kotlin-gradle plugin:$kotlin_version"
         classpath 'com.google.gms:google-services:YOUR_VERSION'
      }
    }
    
    allprojects {
     repositories {
         google()
         mavenCentral()
     }
    }
    
    rootProject.buildDir = '../build'
    subprojects {
     project.buildDir = "${rootProject.buildDir}/${project.name}"
    }
    subprojects {
        project.evaluationDependsOn(':app')
     }
    
     tasks.register("clean", Delete) {
     delete rootProject.buildDir
    }
    
    1. Modify your android.settings.gradle and id "org.jetbrains.kotlin.android" version "YOUR VERSION" apply false and run

      pluginManagement {
          def flutterSdkPath = {
             def properties = new Properties()
             file("local.properties").withInputStream { properties.load(it) }
             def flutterSdkPath = properties.getProperty("flutter.sdk")
             assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
      }()
      
      includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
      
      repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
      }
      }
      
       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 "2.0.0" apply false
       }
      
        include ":app"
      
Jehanna answered 6/6 at 16:30 Comment(0)
S
0

I experienced this issue today and what worked for me was two things:

  1. I went to this link then I copied the stable version of kotlin.

  2. Then went to my android/settings.gradle file and updated this line to that version. id "org.jetbrains.kotlin.android" version "{COPIED_VERSION}" apply false

Shoplifter answered 16/6 at 15:39 Comment(0)
L
0

I got the same issue "Your project requires a newer version of the Kotlin Gradle plugin." with my new projet created on flutter 3.22.2 (last version).

I noted some changes, in build.gradle, there is not the block buildscript. I started by adding this block in build.gradle: buildscript { ext.kotlin_version = "1.7.10" repositories{google() mavenCentral()} } but it does not fix my issue.

After spending hours and hours trying many solutions, where I got new errors as "The binary version of its metadata is 1.9.0, expected version is 1.7.1".

Finally, to fix the issue, I've cleaned everything and I have just changed this line by adding the new version of kotlin in the file settings.gradle " android/settings.gradle" and the issue was solve from my end.

So, open the file settings.gradle (android/settings.gradle) and update this line by changing version "1.7.10" (current) to version "2.0.0" (the last one).

I changed:

id "org.jetbrains.kotlin.android" version "1.7.10" apply false

to

id "org.jetbrains.kotlin.android" version "2.0.0" apply false

Here is what we have now:

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 "2.0.0" apply false

}

I hope this could help someone like me. The error "Your project requires a newer version of the Kotlin Gradle plugin. " is fixed.

My app is running fine.

Leund answered 16/6 at 18:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.