I can't run my Flutter app and I am getting this error:
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 /Users/blabla/Desktop/projects/blabla/android/build.gradle: ││ ext.kotlin_version = '<latest-version>'
I already updated /android/build.gradle file like this to include newest version:
buildscript { ext.kotlin_version = '1.9.22' repositories { google() mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_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}
I also have this in gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip
My Flutter version is:
Flutter 3.19.1 • channel stable • https://github.com/flutter/flutter.gitFramework • revision abb292a07e (4 days ago) • 2024-02-20 14:35:05 -0800Engine • revision 04817c99c9Tools • Dart 3.3.0 • DevTools 2.31.1
Whatever I try I am getting back to this error, so I am out of ideas and I would appreciate some help.
Adding app/build.gradle:
plugins { id "com.android.application" id "kotlin-android" id "dev.flutter.flutter-gradle-plugin"}def localProperties = new Properties()def localPropertiesFile = rootProject.file('local.properties')if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) }}def flutterVersionCode = localProperties.getProperty('flutter.versionCode')if (flutterVersionCode == null) { flutterVersionCode = '1'}def flutterVersionName = localProperties.getProperty('flutter.versionName')if (flutterVersionName == null) { flutterVersionName = '1.0'}android { namespace "hr.ags.blabla" compileSdkVersion 34 ndkVersion "25.1.8937393" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "hr.ags.blabla" minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } }}flutter { source '../..'}dependencies {}
settings.gradle:
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 } settings.ext.flutterSdkPath = flutterSdkPath() includeBuild("${settings.ext.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 "1.7.10" apply false}include ":app"