Mark
08/19/2025, 8:43 AMandroid { }
block to specify the consumerProguardFiles
but that’s not applicable to a KMP library module.
EDIT: Is this relevant? https://developer.android.com/reference/tools/gradle-api/8.3/null/com/android/build/api/dsl/KmpOptimization
EDIT2: I tried this but it doesn’t seem to help:
kotlin {
android {
optimization {
val file = project.file("proguard-rules.pro")
println("proguard: " + file.canonicalPath) // check it's the right location
consumerKeepRules.files.add(file)
}
}
SOLVED:
androidLibrary {
optimization {
consumerKeepRules.publish = true
consumerKeepRules.files.add(project.file("proguard-rules.pro"))
}
}
zsmb
08/19/2025, 11:14 AMTaush Sampley
08/19/2025, 12:07 PMkeepRules
instead of consumerKeepRules
?Taush Sampley
08/19/2025, 12:11 PMTaush Sampley
08/19/2025, 12:14 PMMark
08/19/2025, 12:24 PMMark
08/19/2025, 12:25 PMzsmb
08/19/2025, 12:26 PMandroidLibrary
(new KMP Android plugin) or androidTarget
(old general Android library plugin)zsmb
08/19/2025, 12:26 PMcom.android.kotlin.multiplatform.library
Mark
08/19/2025, 12:27 PMandroidLibrary { }
and
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.kotlin.multiplatform.library)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.compose.multiplatform)
}
zsmb
08/19/2025, 12:29 PMMark
08/19/2025, 12:30 PMMark
08/19/2025, 12:31 PMzsmb
08/19/2025, 12:38 PMoptimization
API, should be used here
kotlin {
androidLibrary {
optimization {
consumerKeepRules
}
}
}
I don't know what the exact syntax is for adding files to these rules 😄zsmb
08/19/2025, 12:38 PM@Keep
indeed is JVM/Android only, but it seems like it could be a common annotation that's just ignored on other platforms, worth filing an issue for probably
https://developer.android.com/reference/kotlin/androidx/annotation/KeepMark
08/19/2025, 12:46 PMandroid
to androidLibrary
(which makes more sense) but that didn’t help unfortunately. But then I added:
consumerKeepRules.publish = true
and voila!
Thanks to the inspiration from this link: https://android.googlesource.com/platform/frameworks/support/+/4e7d49d349e86d337aa6f1411bff30d7143fc729%5E%21/Mark
08/19/2025, 12:48 PMzsmb
08/19/2025, 12:48 PMMark
08/19/2025, 12:51 PMzsmb
08/19/2025, 12:52 PMzsmb
08/19/2025, 12:53 PMMark
08/19/2025, 12:56 PM