androidflutterkotlindart

flutter : Your project requires a newer version of the Kotlin Gradle plugin


I am trying to build my app after some modification but I get error as shown below

.gradle/caches/transforms-3/431ce31617111116ed092b20fb775fda/transformed/jetified-kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. I have tried so many solutions as suggested by the comunity like

    dependencies {
    constraints {
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
            because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
        }
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
            because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
        }
      }
    }

and also tried to change Kotlin version to :

    buildscript {
    ext.kotlin_version = '1.9.10'
    repositories {
        google()
        mavenCentral()
     }

    }

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

the error comes from my custom package as when I remove it and its corresponding code it just works fine with no error, but there is no android specific code inside this package ,there is only maintained packages inside it as shown in this pubspec.yaml file:

    name: dynamic_views
description: "A new Flutter package project."
version: 0.0.1
homepage:

environment:
  sdk: '>=3.4.1 <4.0.0'
  flutter: ">=1.17.0"

dependencies:
  cached_network_image: ^3.3.1
  carousel_slider: ^4.2.1
  easy_debouncer: ^0.0.2
  fl_chart: ^0.68.0
  flutter:
    sdk: flutter
  flutter_animate: ^4.5.0
  flutter_riverpod: ^2.5.1
  geekyants_flutter_gauges: ^1.0.4
  geolocator: ^12.0.0
  google_maps_flutter: ^2.6.1
  iconsax: ^0.0.8
  image_picker: ^1.1.1
  intl: ^0.19.0
  lottie: ^3.1.2
  mobile_scanner: ^5.1.1
  pie_chart: ^5.4.0


dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^4.0.0

#every thing is works fine for IOS side of the app!


Solution

  • It's recently a common problem, You can adjust kotlin version in settings.gradle file.

    You can find it in android folder level, android/settings.gradle:

    plugins {
        id "org.jetbrains.kotlin.android" version "1.9.24" apply false
    }
    

    you can keep track the newer versions of kotlin from here