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.
3
Answers
Run this command in Terminal
Then Run [File – from android studio menu]
I encountered this issue and followed the instructions below to ensure my project was configured to support Kotlin. It turns out Kotlin was not a dependency of mine.
https://capacitorjs.com/docs/plugins/android#using-kotlin
Once that is done, the following will have been added to build.gradle:
$kotlin_version can be defined at the top of the buildscript, so it looks something like this:
I have the same problem today and solved it by changing the Gradle user home.
This build error happens when the Gradle files have broken.
You can change the Gradle user home from
After resetting the Gradle user home directory, the Gradle will re-download the necessary files to build the project. It should work after the re-download and re-initiate the Gradle files in the user home directory.