21

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?

3
  • Have you tried "Reload All Gradle Project"? Are there any error messages when you running gradlew --tasks? Commented Mar 10, 2021 at 9:16
  • Also gradle script support goes wild if there is some problem with applied gradle plugins... Commented Mar 10, 2021 at 9:19
  • What error is reported when you hover over the error in Editor?
    – Andrey
    Commented Mar 10, 2021 at 13:28

6 Answers 6

6

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

2
  • 13
    didn't work for me, not even with clearing ~/.gradle/caches
    – Abacus
    Commented Mar 17, 2021 at 9:18
  • 2
    same problem for me
    – Joergi
    Commented Jul 22, 2021 at 8:47
6

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.

1

Adding the following line to gradle.properties fixed the issue in my case

org.gradle.dependency.verification=lenient

Related issue https://youtrack.jetbrains.com/issue/KTIJ-21452

0
0

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.

0

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.

0

I implemented all the above solutions, none of them worked. But when i moved the root folder location on my Mac using Finder to a different location, the red squiggly lines vanished.

Disclaimer: the red lines started appearing for me when I changed the project name and root folder name. So this fix may not work if the cause of your issues are different.

Not the answer you're looking for? Browse other questions tagged or ask your own question.