Hey everyone, not sure if this's the correct channel for this, does anyone here have experience obfuscating android artifacts in kmp projects with r8 using proguard-rules instead of consumer-rules?
I have a kmp project with just one target currently (Android) and i want to publish it with everything that is private or internal obfuscated, problem is that r8 is removing the kotlin metadata from the aar which disables stuff like extension functions and named arguments for library consumers
Ahmed Mourad
09/27/2025, 5:24 PM
I have the rules for keeping the metadata but they seem to be ignored by r8
Copy code
-dontshrink
-keep class kotlin.Metadata { *; }
-keepattributes *Annotation*, InnerClasses, Signature, EnclosingMethod, SourceFile, LineNumberTable, MethodParameters
-keep public class my.package.** {
public *;
}
Ahmed Mourad
09/27/2025, 5:25 PM
When using the library, instead of extension functions, i only see the *Kt classes that kotlin generates for java users
e
ephemient
09/27/2025, 6:12 PM
that sounds like you're not packaging the
*.kotlin_module
files
ephemient
09/27/2025, 6:16 PM
although… r8 is more for optimization than obfuscation and I don't see a point to applying that to the android artifacts. if you're trying to hide something, it'll still be visible (with a little bytecode inspection or by looking at the other multiplatform artifacts), and if you're trying to optimize the library, that will be done more completely at the consumer
☝🏻 1
a
Ahmed Mourad
09/28/2025, 11:37 AM
that sounds like you're not packaging the
*.kotlin_module
files
I definitely don't see it in the output AAR so that might be it, i'm not sure why it's being removed though or do i need to manually include it?
if you're trying to hide something, it'll still be visible (with a little bytecode inspection or by looking at the other multiplatform artifacts)
I'm mainly interested in obfuscating the private / internal implementations of the library, what would be the best solution for this?