println (and all of kotlin.io) show up as 'unresolved reference' in IntelliJ after updating kotlin to version 1.4.10 from 1.3.72

Viewed 1254

In, quite literally a hello world project the IDE seems to think println and any other parts of kotlin.io are not resolved.

Unresolved reference

The project builds and runs just fine, however. The issue exists in 1.4.0 but not 1.3.72.

The io package in kotlin-stdlib-1.4.10.jar the IDE seems to think is missing, even though it really isn't (ss attached) missing io package

The following is my build.gradle. Changing 1.4.10 to 1.3.72 fixes all the problems.

plugins {
    kotlin("jvm") version "1.4.10"
}

group = "ga.rubydesic"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib-jdk8"))
}

tasks {
    compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
    compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
}
2 Answers

Had a similar-sounding issue and wanted to add what happened / solved it:

Our code was using 1.4.20, but a gradle dependency was causing us to also include 1.4.30. Gradle didn't care, but it caused IntelliJ to stop resolving kotlin.io. Weirdly, existing IntelliJ projects continued to work, but fresh checkouts were seeing the problem.

Once we upgraded to 1.4.30, IntelliJ was fine again. Seemingly, multiple 1.4.x versions caused this problem.

I have noted the same issue in IntelliJ 2020.2, Kotlin 1.4.10 and gradle. Switching back to 1.3.72 works fine. Funny thing is it compiles ok, just red markers for things like println and listOf and no code completion.

Related