My project requires a newer version of the Kotlin Gradle plugin, but the suggested fix doesn't work

814

Solution 1

try this

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

and go android>gradle>wrapper>gradle-wrapper.properties file change zip file version

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

Solution 2

change the kotlin version in build.gradle from XXX to 1.6.10 or to newer version

build.gradle>gradle>android

Share:
814
miguel alves miguel
Author by

miguel alves miguel

Updated on January 03, 2023

Comments

  • miguel alves miguel
    miguel alves miguel over 1 year

    so I just upgraded flutter and quickly got this error:

    ┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────┐
    │ [!] 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 C:\Users\myUsername\Desktop\Swiper\Swiper-main\android\build.gradle:                  │
    │ ext.kotlin_version = '<latest-version>'                                                      │
    └──────────────────────────────────────────────────────────────────────────────────────────────┘
    Exception: Gradle task assembleDebug failed with exit code 1
    Exited (sigterm)
    

    This is a known breaking change when upgrading.

    I applied the suggested fix but the error doesn't go away

    Here is my \android\build.gradle:

    buildscript {
        ext.kotlin_version = '1.6.10' //there was nothing here before
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:4.1.0'
            classpath 'com.google.gms:google-services:4.3.5'
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    (...)
    

    Things I tried:

    -flutter clean

    -Restart VS Code

    -Turn off and cold boot emulator again.

    -Looking at similar threads

    -Adding implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10" to my app/build.gradle

    -Open /android in Android Studio and trying to Gradle Sync (Gradle sync failed: Sync failed: reason unknown (1 m 26 s 622 ms))

  • MartinT
    MartinT about 2 years
    It's better to prefer textual answers over screenshots. The reason is allowed copy-paste and confidence the link will not become invalid in future.