```plugins { kotlin("multiplatform") kotli...
# android
k
Copy code
plugins {
    kotlin("multiplatform")
    kotlin("plugin.serialization")
    id("com.android.library")
    id("maven-publish")
    id("com.github.ben-manes.versions")
    ...
}

repositories {
    mavenCentral()
    maven("<https://jitpack.io>")
}

java {
    sourceCompatibility = JavaVersion.VERSION_15
    targetCompatibility = JavaVersion.VERSION_15
}

kotlin {
    androidTarget {
        compilations.all {
            compileTaskProvider.configure {
                compilerOptions {
                    jvmTarget = JvmTarget.JVM_1_8
                }
            }
        }
    }
}

android {
    compileSdk = 34
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")

    defaultConfig {
        minSdk = 28
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    packaging {
        resources {
            excludes += "META-INF/versions/9/OSGI-INF/MANIFEST.MF"
        }
    }
}

kotlin {
    targets.configureEach {
        compilations.configureEach {
            compileTaskProvider.configure {
                compilerOptions {
                    freeCompilerArgs.add("-Xexpect-actual-classes")
                }
            }
        }
    }

    sourceSets {
        all {
            languageSettings.optIn("kotlin.ExperimentalStdlibApi")
            languageSettings.optIn("kotlin.uuid.ExperimentalUuidApi")
            languageSettings.optIn("kotlin.io.encoding.ExperimentalEncodingApi")
        }

        val androidMain by getting {
            dependencies {
                ...
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
                implementation("io.github.oshai:kotlin-logging:7.0.4")
            }
        }
        val androidInstrumentedTest by getting {
            dependencies {
                implementation(kotlin("test"))
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1")
                implementation("androidx.test.ext:junit:1.2.1")
                implementation("androidx.test:runner:1.6.1")
                implementation("androidx.test:rules:1.6.1")
            }
        }
        
        all {
            languageSettings.enableLanguageFeature("InlineClasses")
        }
    }
}
Any idea why the Gradle sync / compilation error message
Source set 'androidMain' of project '<module name>' is part of several compilations [debug, release]
would be caused by this
build.gradle.kts
?
s
How are you trying to build your app? Are you using the Android Studio run button, or manually specifying gradle commands?
k
It already occurs when pressing the "Sync Gradle Changes (Ctrl+Shift+O)" button, and the same thing when pressing the "Build Project (Ctrl+F9)" green hammer button, which I think also invokes the gradle sync beforehand
Issue appears to have been a third party Gradle compiler plugin (suspend-transform) incorrectly configuring the multiplatform dependency
s
Tried disabling plugins one by one... finally found out that atomifu was the culprit. Upgrading it to version 0.27.0 solved the issue.