Berkay Kireçci
Berkay Kireçci

Reputation: 755

"Code insight unavailable" warning while using kotlin dsl

I started to migrate groovy gradle scripts to kotlin dsl and didn't encounter any problem with build.gradle and settings.gradle files. I have several scripts that i apply in build.gradle.kts. When i change these scripts to kotlin dsl, android studio shows "Code insight unavailable (scripts configuration wasn't received.)" message and yet scripts are still working.

I have scripts directory under root project and this is how i apply in build.gradle.kts:

apply(from = "../scripts/ktlint.gradle.kts")

Example script file :

val ktlint by configurations.creating

tasks.register<JavaExec>("ktlint") {
  description = "Check Kotlin code style."
  main = "com.pinterest.ktlint.Main"
  classpath = ktlint
  args = listOf("src/**/*.kt")
}

tasks.register<JavaExec>("ktlintFormat") {
  description = "Fix Kotlin code style deviations."
  main = "com.pinterest.ktlint.Main"
  classpath = ktlint
  args = listOf("-F", "src/**/*.kt")
}

dependencies {
  ktlint(libs.ktlint)
}

I tried to move scripts directory to under app module and buildSrc but the warning didn't resolve. Appreciate any help.

Upvotes: 2

Views: 2457

Answers (2)

Berkay Kire&#231;ci
Berkay Kire&#231;ci

Reputation: 755

Problem is solved, it's because my buildSrc implementation was wrong. This topic helped me a lot.

Upvotes: -2

ItzDavi
ItzDavi

Reputation: 1078

Searching online didn't lead me to a straight answer but:

From this answer

I've tried to set a Gradle project with two subprojects: "app" and "core". I didn't follow the examples correctly and I didn't include references in settings.gradle.kts.

rootProject.name = "MyProject"
include("app", "core") // <-- Line added

So, did you correctly imported your subproject during the migration ?

Since online is really poor of information about this problem, I would go with the "old" way

File -> Invalidate Caches -> Restart

Build -> Clean Project / Rebuild Project

If nothing works, I would suggest you start again the migration guide from official documentation or from here. If again, nothing works, I would file a bug report and submit it to YouTrack

Upvotes: 1

Related Questions