Search code examples
androidproguardobfuscation

How to obfuscate Kotlin Multiplatform code?


To obfuscate Kotlin code we use the isShrinkResources = true property in the build.gradle file. But for the KMP library, I get the following exception: com.android.builder.errors.EvalIssueException: Resource shrinker cannot be used for libraries.

I have isShrinkResources set to true in my base App, yet my KMP library seems to not be obfuscated. Is this expected? Seems like a security oversight?


Solution

  • isShrinkResources is not for obfuscation. isMinifyEnabled is for obfuscation. Read more here https://developer.android.com/build/shrink-code

    Library code doesn't get obfuscated but app code would obfuscate all the code it contains. Libraries would provide proguard-rules to make sure unintended code doesn't get obfuscated.