Returning Crash Information

Is there a way to get ProGuard to return a line # where the crash happened?

Yes this is definitely possible!

To let obfuscated applications or libraries produce useful stack traces that can still be deciphered later on, add the following configuration options to your proguard-project.txt file:

-printmapping out.map
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

With the rules above, we’re keeping all source file attributes, but we’re replacing their values by the string “SourceFile”. We could use any string. This string is already present in all class files, so it doesn’t take up any extra space. If you’re working with J++, you’ll want to keep the “SourceDir” attribute as well.

We’re also keeping the line number tables of all methods. Whenever both of these attributes are present, the Java run-time environment will include line number information when printing out exception stack traces.

The information will only be useful if we can map the obfuscated names back to their original names, so we’re saving the mapping to a file out.map. The ReTrace script tool can then be used to restore the original stack trace with line numbers.

For more information, checkout the ProGuard Manual > Examples Section > Producing useful obfuscated stack traces

1 Like