How to disable DebugMetadata annotation about kotlin.coroutines?

There is a kotlin.coroutines.jvm.internal.DebugMetadata annotation on each class that contains coroutines, the meta data stored on this annotation is useless after class file obfuscated by proguard, and the information of original class file are leaked.

If you do obfuscation (like with Proguard) you can have the tool strip the annotation. Proguard can certainly do it. And it is “valid” as the code is not designed for development anyway.

This annotation is inlined and invoked at kotlin.coroutines.jvm.internal.SuspendLambda#toString, and there is no way to remove toString() method of subclass with Proguard.

I’ve created ‘unmeta’, an Android Gradle plug-in that removes all Kotlin @Metadata and @DebugMetadata annotations for release builds.

You can find it here: GitHub - oliver-jonas/unmeta: An Android Gradle plugin to remove all Kotlin Metadata annotations from the build output.

It uses ASM and operates directly on the compiled bytecode.