skip to Main Content

Facing this error (Could not get unknown property ‘kotlin_version’ for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler) following is the build gradle code.

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.example.forpfl2'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.forpfl2"
        minSdk 16
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies{


    implementation fileTree(dir: "libs", include: [".jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'com.android.volley:volley:1.2.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

2

Answers


  1. dependencies {
    def kotlin_version = "1.8.10"
    ....
    }
    

    You can check the versions on this site.

    Login or Signup to reply.
  2. You have 2 options and can choose any one of them.

    1. Either replace $kotlin_version in your code with the latest kotlin version(1.8.10).
    2. Or define the kotlin_version as def kotlin_version = "1.8.10"
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search