How can I obfuscate my SDK coded with Kotlin (Get rid of Metadata) How can I obfuscate my SDK coded with Kotlin (Get rid of Metadata)

How can I obfuscate my SDK coded with Kotlin (Get rid of Metadata)


Developing a software development kit (SDK) in Kotlin for Android applications is undoubtedly a challenging task. However, when it comes to obfuscating the code to protect your intellectual property, the process can become even more intricate. A common concern among developers is the persistence of Kotlin metadata annotations, even after applying obfuscation techniques such as Proguard. In this article, we will explore a solution provided by the community to eliminate these metadata annotations and enhance the obfuscation of Kotlin-based SDKs.

The Challenge:

A Stack Overflow user raised a pertinent question about obfuscating an Android library coded in Kotlin while facing the issue of lingering @kotlin.Metadata annotations post-obfuscation. These annotations, present at runtime, could potentially expose the internal workings of the SDK, making it susceptible to reverse engineering.


To address this concern, the developer initially utilized Proguard for obfuscation, expecting it to safeguard the code effectively. However, even with meticulous configuration and rules, the @kotlin.Metadata annotations persisted, revealing information that could aid decompilers in reconstructing the original code structure.


After extensive exploration and experimentation, a solution emerged. The key to successfully eliminating Kotlin metadata annotations lies in enabling R8 full mode. By making a simple adjustment to the file, developers can activate R8 full mode and significantly enhance obfuscation.

File :


This addition triggers R8 to operate in full mode, offering more advanced code transformations that effectively remove Kotlin metadata annotations. It’s essential to note that R8 full mode is still undergoing testing, and occasional issues may arise. However, for many developers, including the original poster, it proved to be a successful solution.

Fine-Tuning with Proguard Rules:

To further optimize the obfuscation process, specific Proguard rules were recommended to complement R8 full mode. These rules help in suppressing warnings related to Kotlin and make additional assumptions to enhance the obfuscation process. Here’s an example of Proguard rules that can be included:

File: proguard

-dontwarn kotlin.** -assumenosideeffects class kotlin.jvm.internal.Intrinsics { static void checkParameterIsNotNull(java.lang.Object, java.lang.String); }

These rules contribute to a more seamless obfuscation experience, working in tandem with R8 full mode to ensure that your Kotlin-based SDK remains robustly protected against reverse engineering attempts.


Securing the integrity of your SDK is crucial in a landscape where intellectual property is highly valued. The challenge of obfuscating Kotlin code, especially when dealing with persistent metadata annotations, is now met with a viable solution. By embracing R8 full mode and fine-tuning the process with Proguard rules, developers can enhance the obfuscation of their SDKs, providing a more robust defense against potential code exploitation. As the Android development ecosystem evolves, staying informed about these advanced techniques becomes imperative for developers aiming to fortify their creations in the competitive mobile app landscape.