Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio : Could not get unknown property 'kotlin_version'

After git cloning from here,

I first faced with this error:

1: Task failed with an exception.
-----------
* Where:
Build file 'C:\...\voicegym\app\build.gradle' line: 3

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not initialize class org.jetbrains.kotlin.gradle.internal.KotlinSourceSetProviderImplKt

following this advice, i added these to build.gradle (Project: voicegym)

buildscript {
    ext.kotlinVersion = '1.3.72' // previously  '1.2.60'
    ext.springBootVersion = '2.0.4.RELEASE'
    ext.anko_version='0.10.4'
    repositories {
        ...
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

Now, i have this error

Build file 'C:\...\voicegym\build.gradle' line: 5

A problem occurred evaluating root project 'voicegym'.
> Could not get unknown property 'kotlin_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
like image 546
leonardltk1 Avatar asked Mar 23 '26 05:03

leonardltk1


2 Answers

after experimenting, it should be ext.kotlin_version=... instead of ext.kotlinVersion =...

buildscript {
    ext.kotlin_version= '1.3.72' // previously  '1.2.60'
    ext.springBootVersion = '2.0.4.RELEASE'
    ext.anko_version='0.10.4'
    repositories {
        ...
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
like image 90
leonardltk1 Avatar answered Mar 25 '26 19:03

leonardltk1


All you need to do to fix this error is to add the following line in ext component inside "Android/build.gradle(Project:projectName) file:

kotlin_version = '1.5.31'

The ext component will look like:

ext {
    activityVersion = '1.4.0'
    appCompatVersion = '1.4.0'
    constraintLayoutVersion = '2.1.2'
    coreTestingVersion = '2.1.0'
    coroutines = '1.5.2'
    lifecycleVersion = '2.4.0'
    materialVersion = '1.4.0'
    roomVersion = '2.3.0'
    // testing
    junitVersion = '4.13.2'
    espressoVersion = '3.4.0'
    androidxJunitVersion = '1.1.3'
     //Add the kotlin version here:
    kotlin_version = '1.5.31'
}
like image 20
lordvoldemort Avatar answered Mar 25 '26 19:03

lordvoldemort



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!