Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot access script base class 'org.gradle.kotlin.dsl.KotlinBuildScript'

When I create an empty project with Gradle Kotlin DSL, even without any modifications, it would prompt Cannot access script base class 'org.gradle.kotlin.dsl.KotlinBuildScript'. Check your module classpath for missing or conflicting dependencies The project can run, but the syntax highlighting and autocompletion for build.gradle.kts don't work.

What I've tried

  • https://github.com/gradle/kotlin-dsl-samples/issues/1308
    • Changing gradle executable to gradle-kotlin-dsl-5.2-20190122225509+0000-all.zip
  • https://youtrack.jetbrains.com/issue/KT-38296
    • Remove empty SDKs in Project structure dialog
    • Invalidate caches and restart
  • Reinstalling Java 11 brew install java11
  • Switching to official oracle JDK 15 ​brew install oracle-jdk
  • https://youtrack.jetbrains.com/issue/KT-41141
    • Re-adding SDKs in the SDK menu
    • Adding /Kotlin/kotlinc/lib to Kotlin SDK's classpath
  • http://youtrack.jetbrains.com/issue/IDEA-245027
    • Deleting the cache folder manually

System

IntelliJ IDEA 2020.3.1 (Ultimate Edition) Build #IU-203.6682.168, built on December 29, 2020 Licensed to Hykilpikonna Gui Subscription is active until November 28, 2021. For educational use only. Runtime version: 11.0.9.1+11-b1145.63 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 10.15.7 GC: ParNew, ConcurrentMarkSweep Memory: 1998M Cores: 6 Registry: debugger.watches.in.variables=false, js.debugger.webconsole=false Non-Bundled Plugins: CMD Support, Rider UI Theme Pack, Statistic, com.alayouni.ansiHighlight, com.intellij.ideolog, net.vektah.codeglance, String Manipulation, com.alibaba.p3c.smartfox, wu.seal.tool.jsontokotlin, com.demonwav.minecraft-dev, lermitage.intellij.extra.icons, com.github.masahirosuzuka.PhoneGapIntelliJPlugin, Dart, io.flutter, deno, org.jetbrains.kotlin, com.cybrosis.catdea, siosio.kodkod, izhangzhihao.rainbow.brackets, org.jetbrains.plugins.ruby, Pythonid, org.jetbrains.plugins.vue, tv.twelvetone.intellij.plugins.intellivue, ru.meanmail.plugin.requirements 
like image 328
Hykilpikonna Avatar asked Jan 09 '21 17:01

Hykilpikonna


People also ask

What is kotlin gradle DSL?

Kotlin DSL brings the simplicity of the Kotlin language syntax and rich API set right into the script files on top of that code completion makes it perfect to work with Gradle script files. We will use this to manage our dependencies and project settings configurations more elegantly.

What is DSL in Gradle?

Simply, it stands for 'Domain Specific Language'. IMO, in gradle context, DSL gives you a gradle specific way to form your build scripts. More precisely, it's a plugin-based build system that defines a way of setting up your build script using (mainly) building blocks defined in various plugins.

What is Kotlin DSL?

The Navigation component provides a Kotlin-based domain-specific language, or DSL, that relies on Kotlin's type-safe builders. This API allows you to declaratively compose your graph in your Kotlin code, rather than inside an XML resource. This can be useful if you wish to build your app's navigation dynamically.


1 Answers

Answer credit to @AlexeyBelkov - Answered here: https://youtrack.jetbrains.com/issue/KTIJ-893

The syntax highlighting feature worked after:

  1. Delete ~/.gradle/caches
  2. Delete ~/Library/Application\ Support/Library/JetBrains/IntelliJIdea2020.3 (or ~/.cache/JetBrains/IntelliJIdea2020.3 for ubuntu/linux users)
  3. Delete <project dir>/.gradle
  4. Delete <project dir>/.idea
  5. Start IDEA and reimport the project.
like image 68
Hykilpikonna Avatar answered Oct 09 '22 15:10

Hykilpikonna