Search code examples
androidandroid-studiokotlingradlebuild.gradle

Unable to load class 'org.jetbrains.kotlin.config.LanguageVersion'


When I bought the new laptop, to copy my android studio projects from old laptop to new laptop, I just copied all the projects from the folder AndroidStudioProjects to respective folder in new laptop.

Usually it used to work. But this time, I am getting a new error while gradle sync.

When I try to run a copied project, in the process of gradle sync, I am getting following error.

Unable to load class 'org.jetbrains.kotlin.config.LanguageVersion'.

This is an unexpected error. Please file a bug containing the idea.log file.

and

org/jetbrains/kotlin/config/LanguageVersion
> org.jetbrains.kotlin.config.LanguageVersion

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
java.lang.NoClassDefFoundError: org/jetbrains/kotlin/config/LanguageVersion
    at org.jetbrains.kotlin.gradle.plugin.sources.FragmentConsistencyChecks.<init>(ConsistencyChecker.kt:24)
    at org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKt.<clinit>(DefaultKotlinSourceSet.kt:210)
    at org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet.<init>(DefaultKotlinSourceSet.kt:62)
    at org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetFactory.doCreateSourceSet(KotlinSourceSetFactory.kt:162)
    at org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetFactory.doCreateSourceSet(KotlinSourceSetFactory.kt:65)
    at org.jetbrains.kotlin.gradle.plugin.sources.KotlinSourceSetFactory.create(KotlinSourceSetFactory.kt:30)
    at org.jetbrains.kotlin.gradle.plugin.sources.KotlinSourceSetFactory.create(KotlinSourceSetFactory.kt:23)


//I have trimmed the stack trace.

Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.config.LanguageVersion
    ... 230 more

Not only by copying from other laptop to new laptop, even when I try to fetch the full project from version control, I am getting the same error.

There is not enough resources available online for it.

Any help would be appreciated.


Solution

  • Maybe you are using too old com.google.devtools.ksp for kotlin 1.8.10. Try to update it to version 1.8.21-1.0.11:

    id("com.google.devtools.ksp") version "1.8.21-1.0.11" apply false

    I encountered such a problem