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

Marc

11/15/2023, 2:41 PM
I am having a problem where IntelliJ does not recognise the Android source sets in my KMP project. If I have a common and an Android source set, neither are displayed as code in the the IDE and everything is just treated the same as any other text. If I however add a JVM source set for example, commonMain and jvmMain get displayed properly (while androidMain is still just a normal folder). I am writing a library and can build and publish the built Android artifacts just fine, yet the IDE doesn't realise that it is working code. I configure the source sets like this:
Copy code
kotlin {
    //jvm()

    androidTarget {
        publishLibraryVariants("release", "debug")
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(libs.napier)
                implementation(libs.kotlinx.datetime)
                implementation(libs.ktor.server.core)
                implementation(libs.ktor.server.cio)
                implementation(libs.ktor.server.resources)
                implementation(libs.ktor.server.contentnegotiation)
                implementation(libs.ktor.server.websockets)
                implementation(libs.ktor.serialization.json)
                implementation(libs.meshwrapper)
            }
        }

        val androidMain by getting {
            dependencies {
                implementation(libs.slf4j.api)
                implementation(libs.slf4j.simple)
            }
        }
    }
}
Is there a way I can get IntelliJ to recognise the androidMain source set?
p

Pavel S

11/15/2023, 4:01 PM
have you applied the android plugin?
m

Marc

11/15/2023, 4:02 PM
I have applied the Kotlin Multiplatform plugin and the Android library plugin, yes. The library does build successfully too and I can use it in another project just fine.
a

Andrew Reed

11/21/2023, 8:08 PM
im also getting this issue where the androidMain and androidUnitTest source sets are not recognised in intellij
they are working in gradle
2 Views