Home > Software engineering >  Error: Your project requires a newer version of the Kotlin Gradle plugin after upgrade it
Error: Your project requires a newer version of the Kotlin Gradle plugin after upgrade it

Time:10-11

while running my project there was an error that

Your project requires a newer version of the Kotlin Gradle plugin.

So, I Go to JetBrains GitHub Repo and found that the latest version is: 1.7.20.

So, I Go to android/build.gradle and change kotlin version to

ext.kotlin_version = "1.7.20"

dependencies {
  classpath 'com.android.tools.build:gradle:7.1.2'
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20"
}

and android/app/build.gradle

apply plugin: 'kotlin-android'

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20"
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.7.20"
}

my gradle-wrapper.properties is distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

result of flutter doctor -v

[√] Flutter (Channel stable, 3.3.2, on Microsoft Windows [Version 10.0.19044.2006], locale en-US)
    • Flutter version 3.3.2 on channel stable at C:\Users\sayed\Documents\flutter_windows_2.2.3-stable\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e3c29ec00c (4 weeks ago), 2022-09-14 08:46:55 -0500
    • Engine revision a4ff2c53d8
    • Dart version 2.18.1
    • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\sayed\AppData\Local\Android\sdk
    • Platform android-33, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13 0-b1751.21-8125866)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C  " workload, including all of its default components

[√] Android Studio (version 2021.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13 0-b1751.21-8125866)

[√] VS Code (version 1.72.0)
    • VS Code at C:\Users\sayed\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.50.0

[√] VS Code, 64-bit edition (version 1.63.0)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.50.0

[√] Connected device (4 available)
    • DRA LX2 (mobile)  • 5LX9K18817915788 • android-arm64  • Android 8.1.0 (API 27)
    • Windows (desktop) • windows          • windows-x64    • Microsoft Windows [Version 10.0.19044.2006]
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 105.0.5195.127
    • Edge (web)        • edge             • web-javascript • Microsoft Edge 106.0.1370.37

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

when build apk or run release errors occurs like this one

Exception: Gradle task assembleRelease failed with exit code 1
#0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1      AndroidGradleBuilder.buildGradleApp (package:flutter_tools/src/android/gradle.dart:446:7)
<asynchronous suspension>
#2      AndroidGradleBuilder.buildApk (package:flutter_tools/src/android/gradle.dart:184:5)
<asynchronous suspension>
#3      AndroidDevice.startApp (package:flutter_tools/src/android/android_device.dart:575:7)
<asynchronous suspension>
#4      FlutterDevice.runCold (package:flutter_tools/src/resident_runner.dart:504:33)
<asynchronous suspension>
#5      ColdRunner.run (package:flutter_tools/src/run_cold.dart:57:28)
<asynchronous suspension>
#6      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:706:27)
<asynchronous suspension>
#7      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1209:27)
<asynchronous suspension>
#8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#10     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
<asynchronous suspension>
#11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#12     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
<asynchronous suspension>
#13     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#14     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#15     main (package:flutter_tools/executable.dart:91:3)
<asynchronous suspension>

How could I solve This problem?

CodePudding user response:

try with higher than 7.2 gradle version, like

distributionUrl = "https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip"

in this path : android\gradle\wrapper\gradle-wrapper.properties

  • Related