Intellij shows every line in build.gradle.kts is red

Viewed 2520

I created a new project from VCS (Kotlin and Gradle). I added three testImplementation() calls to the build.gradle.kts. IntelliJ didn't pickup the changes so I did File -> Invalidate caches / Restart and now Intellij shows every implementation() call and every testImplementation() call in red. In fact every line in every build.gradle.kts in every module is red.

Intellij has lost its mind. What do I have to do to restore IntelliJ's intelligence when it comes to kotlintest in Gradle?

4 Answers

I started seeing this with AS 4.2.1. Invalidating caches and re-importing the project didn't work for me. I found this article on the JetBrains issue tracker where people found that they had an extraneous JDK set in the project settings. While I did not have an extraneous JDK set in my project structure, I tried changing the JDK from the AS embedded version to an alternate AdoptOpenJDK 1.8 version I had installed. After switching to that version all the red went away and everything is resolving as expected. I was then able to switch the SDK back to the embedded version and everything continued working as expected. When switching back to the embedded version I did notice a brief message in the progress bar at the bottom of AS saying that it was processing a JDK 11. I'm not sure where that's coming from, but it does seem to be in line with what others in the JetBrains issue were talking about.

The way I was finally able to solve this was with File -> Invalidate caches / Restart. It must have been cache corruption.

What do I have to do to restore IntelliJ's intelligence when it comes to kotlintest in Gradle?

Re-import the project: File | New | Project from Existing Sources action and select build Gradle file to load the project from.

Change your jdk.

Go to File>Project Structure > SDK Location > GradleSettings

Change the Gradle JDK to use the embedded or a compatible JDK (Azul JDK) if you're using a MAC.

Then Invalidate and refresh cache after deleting the .idea and .gradle files.

Related