Dependencies in kotlin multiplatform project not working

Hi!

I created multiplatform project with IntelliJ IDEA and by default there is build.gradle.kts in common module, it contains this part:

sourceSets {
    val commonMain by getting {
        dependencies {
            api(compose.runtime)
            api(compose.foundation)
            api(compose.material)
        }
    }
}

I want to add some more dependencies, for example:

sourceSets {
    val commonMain by getting {
        dependencies {
            api(compose.runtime)
            api(compose.foundation)
            api(compose.material)
            implementation("com.squareup.okhttp3:okhttp:4.9.0")
        }
    }
}

And the okhttp3 dependencies are not available in the commonMain module, but are available in the desktopMain. What am I doing wrong?

I might be wrong here but I don’t think the square libraries support kotlin-multiplatform. They only compile to for JVM desktop and android. Therefor you can’t use okhttp in a common module.

1 Like

Thank You for explanation!

1 Like