Getting… rid of those missing android* source sets warnings on your KMP project

Carlos Mota
1 min readApr 18, 2022
Getting… rid of those missing android* source sets warnings on your KMP project cover

While cleaning up the warnings in one of my projects, I’ve noticed that there was one that kept showing up:

The following Kotlin source sets were configured but not added to any Kotlin compilation:
* androidAndroidTestRelease
* androidTestFixtures
* androidTestFixturesDebug
* androidTestFixturesRelease
You can add a source set to a target’s compilation by connecting it with the compilation’s default source set using ‘dependsOn’.
See https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets

Although this issue is already reported at KT-48436, you can temporarily a workaround to resolve it. Open the build.gradle.kts file at the root of your shared project and look for the allprojects section, and add:

afterEvaluate {
project.extensions.findByType<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension>()?.let { ext ->
ext.sourceSets.removeAll { sourceSet ->
setOf(
"androidAndroidTestRelease",
"androidTestFixtures",
"androidTestFixturesDebug",
"androidTestFixturesRelease",
).contains(sourceSet.name)
}
}
}

If you don’t have this section, don’t forget to add it before:

allprojects {

afterEvaluate {
project.extensions...
}

That’s it! Compile your project: one less warning! 🙌

Do you have a better approach? Something didn’t quite work with you?

You are welcome to reply here or send me a message 🙂

https://twitter.com/cafonsomota

--

--

Carlos Mota

👨‍💻, 🔭🌖, 🗺, 📸, 🏃‍💨, 🇵🇹, 🖖 - is this how I should use emojis? Also: https://www.cafonsomota.xyz/