Anirudh Gupta
11/10/2025, 11:42 AMkotlin {
...
androidTarget {
publishLibraryVariantsGroupedByFlavor = false
publishLibraryVariants("release", "debug")
}
...
}
but this does not work. (The target 'android' already exists, but it was not created with the 'android' preset)
• I have even tried manually applying the com.android.library alongside the existing multiplatform library plugin (com.android.kotlin.multiplatform.library) to configure the build variants manually, but that throws the error that both plugins cant be used together.
Attaching my build.gradle.kts for reference:
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidKotlinMultiplatformLibrary)
alias(libs.plugins.androidLint)
alias(libs.plugins.composeMultiplatform)
alias(libs.plugins.composeCompiler)
alias(libs.plugins.composeHotReload)
id("org.jetbrains.kotlin.plugin.serialization")
}
compose.resources {
publicResClass = true
generateResClass = always
}
kotlin {
androidLibrary {
namespace = "com.sample.library"
compileSdk = 36
minSdk = 21
androidResources {
enable = true
}
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
withHostTestBuilder {
}
withDeviceTestBuilder {
sourceSetTreeName = "test"
}.configure {
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
val xcfName = "composeAtomicKit"
iosX64 {
binaries.framework {
baseName = xcfName
}
}
iosArm64 { .. }
iosSimulatorArm64 { ..}
jvm()
js {
browser()
binaries.executable()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
binaries.executable()
}
sourceSets {
commonMain {
dependencies { .. }
}
androidMain {
dependencies {
..
}
}
iosMain { ... }
}
}ephemient
11/10/2025, 11:50 AMPablichjenkov
11/10/2025, 3:26 PMAnirudh Gupta
11/10/2025, 5:53 PMPablichjenkov
11/10/2025, 5:58 PMzsmb
11/10/2025, 5:59 PMPablichjenkov
11/10/2025, 6:00 PMPablichjenkov
11/10/2025, 6:04 PMAnirudh Gupta
11/10/2025, 6:14 PMandroid library targets, right? that would solve the problem.
I saw that we can do multiple targets for jvm("targetName").