skip to Main Content

I have the below error with my Flutter application.

Running Gradle task 'assembleDebug'...                             35.5s  

[!] 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 the version number of the plugin with id "org.jetbrains.kotlin.android" in the plugins block of C:Usersmohammed ishamrental_appandroidsettings.gradle.

Alternatively (if your project was created before Flutter 3.19), update C:Usersmohammed ishamrental_appandroidbuild.gradle

ext.kotlin_version = '<latest-version>'

I have tried these solutions.

Summary of Fixes by AI-generated down here and fixed by me

  1. Updated Kotlin Version:

    • Changed Kotlin version to 1.7.0 in build.gradle and settings.gradle.
  2. Gradle Configuration:

    • Updated Gradle wrapper to gradle-8.0.2 in gradle-wrapper.properties.
    • Ensured the Android Gradle plugin version was compatible.
  3. Dependency Updates:

    • Updated dependencies in pubspec.yaml.
    • Ran flutter pub upgrade and flutter pub get.
  4. Java Configuration in Android Studio:

    • Verified JDK installation (version 11 or higher).
    • Set JDK path in Android Studio’s Project Structure.
    • Configured JAVA_HOME environment variable correctly.
    • Restarted Android Studio and invalidated caches.
  5. Clean and Rebuild Project:

    • Executed flutter clean, followed by flutter build apk --release.

i have even upgraed to the current version of kotlin and tried running it again and again its not working at all and all the ai fixes i have done

2

Answers


  1. https://docs.gradle.org/current/userguide/compatibility.html#kotlin

    Check the embedded kotlin version that compaitable with your Gradle version. If not upgrade the kotlin version to higher level or latest one then

    flutter build clean 
    flutter pub get
    

    Run your app again

    Login or Signup to reply.
  2. Here are some more steps and modifications that could be helpful in overcoming this problem:

    1. Check Kotlin Version’s Compatibility with Gradle:

    At times, there exists a need for some versioning operation between Kotlin plugin and gradle plugin’s version. The documented compatibility in the official Kotlin and Gradle release should be referred to.

    If you are using Kotlin 1.7.0 then try to use it with Android Gradle plugin version seven point zero two or above.

    2. Check Plugin Configurational Settings Once Again:

    Make sure in your build.gradle (Project level) that you have:

    dependencies { 
    classPath ‘org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0’ 
    } 
    

    Now, in the settings.gradle file, the approach should be of putting in the piece concerning the Kotlin plugin like this:

    gradle

    plugins { 
    id ‘org.jetbrains.kotlin.android’ version ‘1.7.0’ apply false 
    } 
    

    3. Gradle Wrapper Update:

    If you see the gradle wrapper version has been upgraded to eight point zero two, look for this in the gradle-wrapper.properties:

    properties

    distributionUrl=https://services.gradle.org/distributions/gradle-8.0.2-all.zip 
    

    4. Use Compatible Java Version:

    Java 11 for Flutter and Android development is required in this case, ensure that your JAVA_HOME passes for a JDK 11 path.

    Check your Java version by using:

    bash

    java – version
    

    5. Clear Cached Builds and Dependencies:

    To remove any remnants of past builds and dependencies, please execute the following commands:

    bash

    flutter clean
    rm -rf ~/.gradle/caches/
    flutter pub get
    flutter build apk –debug
    

    6. Ensure Android Gradle Plugin versions compatibility:

    In your project, open the android/build.gradle file, and ensure that com.android.tools.build:gradle is updated to the latest compatible with the Kotlin version in your project.

    For instance:

    gradle

    classpath "com.android.tools.build:gradle:7.2.1"
    

    7. Check SDK Versions compatibility:

    In android/build.gradle, ensure that compileSdkVersion and targetSdkVersion are updated and lines of code match the latest dependencies applied in the code.

    8. Android Studio: Clear Cache:

    In some cases, caches can be very stubborn. In your version of Android Studio use File > Invalidate Caches / Restart and then try to build again.

    If you have done all the above mentioned, kindly tell me if you still encounter an error or the error notice has changed, and then we can further troubleshoot the situation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search