https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
g

Gabriel Feo

11/20/2019, 3:35 PM
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:
Copy code
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"))
            }
        }
    }
}
r

russhwolf

11/20/2019, 3:50 PM
You don't need
dependsOn(commonMain)
in
jvmMain
. That might be confusing the IDE.
g

Gabriel Feo

11/20/2019, 3:59 PM
@russhwolf, thanks, that was added by the IDE template. I removed it, but still no luck
s

Sebastian Sellmair [JB]

11/20/2019, 4:22 PM
What versions Kotlin (Gradle Plugin, IDE Plugin) are you currently using?
g

Gabriel Feo

11/20/2019, 5:10 PM
Kotlin plugin for Gradle: 1.3.50 Kotlin plugin for IDEA: 1.3.60-release-IJ2019.2-1 IDEA Ultimate 2019.2.4
r

russhwolf

11/20/2019, 5:12 PM
Oh interesting if it's in the template then that's new.
s

Sebastian Sellmair [JB]

11/20/2019, 5:15 PM
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 ☺️ )
e

Erik Christensen

11/20/2019, 5:35 PM
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.
g

Gabriel Feo

11/22/2019, 10:50 AM
@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
2 Views