Android target in Kotlin MPP project

Another day - another gradle\kotlin tooling glitch :frowning: :angry:

Kotlin MPP project - common, js, jvm and (new) android traget. androidMain is not added as proper source root in most recent Idea 2023.3.3, it does not have implicit dependency on commonMain. Again it is impossible to figure out what needs to be done to setup this type of project. Kotlin documentation does not have enough of details. Can anybody help please?

Example project is attached. (5.6 KB)

plugins {
    id 'org.jetbrains.kotlin.multiplatform'
    id ''
    id 'maven-publish'

android {
    compileSdk  34
    namespace = "com.gradle_glitches"

    defaultConfig {
        //applicationId = "com.gradle_glitches"
        minSdk = 26
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    kotlin {

kotlin {
    def ENV = System.getenv()

    androidTarget("main") {

    sourceSets {
        androidMain {
            dependencies {
                //compileOnly files("C:/tools/android-sdk/platforms/android-34/android.jar")
                compileOnly files("$ANDROID_HOME/platforms/android-${android.compileSdk}/android.jar")

Solved. This does the trick:

But androidMain should implicitly depend on commonMain, should not it?

And now I am getting a warning:

The Default Kotlin Hierarchy Template was not applied to 'project ':Core'':
Explicit .dependsOn() edges were configured for the following source sets:

Consider removing dependsOn-calls or disabling the default template by adding
to your

UPD: Probably this is the reason

Kotlin doesn't currently support sharing a source set for these combinations:

* Several JVM targets
* JVM + Android targets

No, it is unbereable. One blocker after another. Android classes are not linked, kotlin methods from standard library are not linked in Idea 2023.3.3. All this tooling is just AWFUL! Idea 2023.3.3 has one set of glitches, 2023.2.4 has another. Nothing works anywhere! :rage: Instead of doing work I am spending my time hitting head against walls(

Idea 2023.3.3:

Idea 2023.2.4:

UPD2: It appears androidTarget works only in Android Studio