Search code examples
javadebuggingintellij-ideaproguardobfuscation

Debug obfuscated application with IntelliJ


I have project with multiple modules and each module consist of API and Implementation jar. We used Proguard to obfuscate this jars. Now we wanted to debug the obfuscated jars to findout issues with the application. Basically we encountering some strange issues only with the obfuscated jars.


Solution

  • We could achieve debugging with the following steps

    Proguard Setup

    • Define mapping file during the obfuscation ( -printmapping application.map)

    • Keep SourceFile and LineNumberTable info during obfuscation

      -renamesourcefileattribute SourceFile
      -keepattributes  SourceFile,LineNumberTable
      

    IntelliJ

    • Create a empty Java project

    • Right click on the project & Open the Module Settings-> Library

    • Add all the obfuscated library jars to the project

    • Findout the class name where you wanted to put break point from the mapping file (application.map)

    • Open the obfuscated class in IntelliJ and add break point

    • Create a new Remote Debug configuration IntelliJ Remote Debugging

    • Launch the application with the debug parameters

        "C:/Program Files 
        (x86)/Java/jre8/bin/java.exe"  - 
         agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
      
    • Application stops at your break point.