Site icon Android Tutorial Online

Remove Kotlin Coroutines DebugMetadata annotations from .class files

Unmeta Gradle Plugin for Android

A gradle plugin for Android Project to remove all Kotlin @DebugMetadata annotations from the compiled classes.

Kotlin Coroutines’ @DebugMetadata annotations are not fully processed by ProGuard / R8 and contain un-obfuscated symbol information, both in binary and plain text forms. This information can be used to more easily reverse engineer your code.

This plugin allows removing all Kotlin @DebugMetadata annotations from generated class files in * release* build.

Usage

In order to make Unmeta work with your project you have to apply the Unmeta Gradle plugin to the project. Please notice that the Unmeta plugin must be applied after the Android plugin.

Plugin DSL

// Project build.gradle.kts
plugins {
  id("com.axzae.unmeta") version "1.1.0" apply false
}

// Module(app) build.gradle.kts
plugins {
  // id("com.android.application")
  // ...
  id("com.axzae.unmeta")
}

Legacy Plugin Application

// Project build.gradle.kts
buildscript {
  dependencies {
    classpath("com.axzae:unmeta:1.1.0")
  }
}

// Module(app) build.gradle.kts
plugins {
  // id("com.android.application")
  // ...
  id("com.axzae.unmeta")
}

Configuration

Unmeta task is bound to all release builds by default hence configuration is optional. However, the lib does expose a few configurable properties:

unmeta {
  isEnabled.set(true) // Default: true
  verbose.set(true) // Default: false
}

Report

Generated task report is located at $BUILD_DIR/outputs/logs/unmeta-report.txt

Start dropping @DebugMetadata from kotlin classes
- Removed @DebugMetadata annotation from com\example\main\MainActivity$greetings$2.class
- Removed @DebugMetadata annotation from com\example\main\MainActivity$onCreate$2.class
Task finished.
Class files scanned: 7
Class files modified: 2
Execution time: 12ms.

Contributing

Feel free to open an issue or submit a pull request for any bugs/improvements.

License

Copyright (c) 2023 Axzae

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

GitHub

View Github

Exit mobile version