Gabriel Feo

    Gabriel Feo

    2 years ago
    Hi! I'm starting out with multiplatform, but IDEA is pointing out usages of java packages in my code as unresolved references, even though the project compiles (any
    java.*
    reference). Has anyone run into this?
    This is my module’s build script:
    plugins {
        id("org.jetbrains.kotlin.multiplatform")
    }
    repositories {
        mavenCentral()
    }
    
    kotlin {
        jvm()
        sourceSets {
            val commonMain by getting {
                dependencies {
                    implementation(kotlin("stdlib-common"))
                }
            }
            val commonTest by getting {
                dependencies {
                    implementation(kotlin("test-common"))
                    implementation(kotlin("test-annotations-common"))
                }
            }
            val jvmMain by getting {
                dependsOn(commonMain)
                dependencies {
                    implementation(kotlin("stdlib-jdk8"))
                }
            }
            val jvmTest by getting {
                dependencies {
                    implementation(kotlin("test"))
                    implementation(kotlin("test-junit"))
                }
            }
        }
    }
    russhwolf

    russhwolf

    2 years ago
    You don't need
    dependsOn(commonMain)
    in
    jvmMain
    . That might be confusing the IDE.
    Gabriel Feo

    Gabriel Feo

    2 years ago
    @russhwolf, thanks, that was added by the IDE template. I removed it, but still no luck
    Sebastian Sellmair [JB]

    Sebastian Sellmair [JB]

    2 years ago
    What versions Kotlin (Gradle Plugin, IDE Plugin) are you currently using?
    Gabriel Feo

    Gabriel Feo

    2 years ago
    Kotlin plugin for Gradle: 1.3.50 Kotlin plugin for IDEA: 1.3.60-release-IJ2019.2-1 IDEA Ultimate 2019.2.4
    russhwolf

    russhwolf

    2 years ago
    Oh interesting if it's in the template then that's new.
    Sebastian Sellmair [JB]

    Sebastian Sellmair [JB]

    2 years ago
    Try upgrading to gradle 1.3.60. We have seen so many MPP issues being resolved with 1.3.60
    (We are using it since the first eap. Works really well ☺️ )
    Erik Christensen

    Erik Christensen

    2 years ago
    I've seen some weirdness where Java classes can't be found in the IDE. Haven't digged into too much, but I've found that changing the Java version in Project Settings usually does the trick.
    It seems to keep changing my target Java version to 11, which is at odds with the Gradle configuration, which is set to 8. When I set it back to 8, it magically starts working again.
    Gabriel Feo

    Gabriel Feo

    2 years ago
    @russhwolf @Sebastian Sellmair [JB] @Erik Christensen Thank you all! I think changing my target Java version is what did it, which is weird because I didn’t have this set in Gradle at all, so IDEA should be working with version 11, but it started working once I changed it to version 8