skip to Main Content

I am doing a flutter project and currently trying to connect the project to firebase database. However I got some issue regarding the kotlin version.

This is my error

Error

This is my code for the build.gradle in the android file

buildscript {
    ext.kotlin_version = '1.7.1'
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.4.1'
        classpath "org.jetbrain.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
}

This is my code for the build.gradle in the android/app file

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id 'com.google.gms.google-services'
}

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 "com.example.clinicconnect_test"
    compileSdk flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    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 "com.example.clinicconnect_test"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 21
        targetSdkVersion 34
        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 {
    implementation 'com.google.android.gms:play-services-maps:18.2.0'
    implementation(platform("com.google.firebase:firebase-bom:32.8.0"))
    implementation("com.google.firebase:firebase-analytics")
    implementation "org.jetbrain.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

I have tried multiple solution from various sources but unable to resolve the issue. Please help me

2

Answers


  1. It’s org.jetbrains.kotlin not org.jetbrain.kotlin.

    (They say two brains are better than one.)

    Login or Signup to reply.
  2. You can try to change this line ext.kotlin_version = '1.9.23'

    androidbuild.gradle
    

    Also always check the latest version of the Kotlin at their site :

    https://kotlinlang.org/docs/releases.html#release-details
    

    Also, classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    If any of above dossn’t work you can create new flutter app and try to compare the build.gradle file.

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