10

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.
3
  • 1
    seems like something wants kotlin_version but you have defined kotlinVersion Commented Nov 14, 2020 at 14:17
  • @a_local_nobody so should i set ext.kotlin_version= '1.3.72' or should i set classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion " Commented Nov 14, 2020 at 17:21
  • not really sure honestly, just make sure you use the same reference everywhere Commented Nov 14, 2020 at 17:22

5 Answers 5

13

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"
    }
}
4

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'
}
2

Inside android/build.gradle file place below code:

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

dependencies {
    classpath 'com.android.tools.build:gradle:7.0.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 }
}

Inside app/build.gradle file place below code:

dependencies {
 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
2

On sdk 46 or higher, your 'gradle.build' should look like this:

ext {
        buildToolsVersion = findProperty('android.buildToolsVersion') ?: '33.0.0'
        minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
        compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '33')
        targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '33')
        if (findProperty('android.kotlinVersion')) {
            kotlinVersion = findProperty('android.kotlinVersion')
        }
        frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }

Just replade it with this:

ext {
        buildToolsVersion = findProperty('android.buildToolsVersion') ?: '33.0.0'
        minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
        compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '33')
        targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '33')
        kotlinVersion = 'X,Y,Z' // <-- Pass your android version here
        frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }

As seen above you'll need to find your android version Mac: Click Android Studio -> Settings -> Languages & Frameworks -> Kotlin

You should see something like this: 213-1.7.20-release-for...

The second set of digits are your android version.

Your dependencies should also look like this:

dependencies {
        classpath('com.android.tools.build:gradle:7.4.1')
        classpath('com.facebook.react:react-native-gradle-plugin')
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") // <-- Add this line
}
1

just add ext.kotlin_version= "1.3.72" like this

buildscript {
    ext.kotlin_version = "1.3.72"
    repositories {

the error will definetly resolved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.