What does --keepattributes SourceFile in Proguard do?

721 Views Asked by At

I'm trying to figure out how Firebase will do the mapping from obfuscated code to real code and according to their docs, I need to add this line -

-keepattributes SourceFile,LineNumberTable

This is supposed to keep the file names and line numbers intact. However, despite using this configuration, I noticed that after decompiling my APK, it contains obfuscated file names like a.java, b.java etc. Additionally, I read in this answer that the SourceFile is just a String which can be renamed. I don't understand this.

My questions are

  1. What is the SourceFile attribute?
  2. Why does keeping the SourceFile attribute still obfuscate the files despite the documentation saying that file names are kept intact?
  3. Why is the SourceFile attribute re-namable?
1

There are 1 best solutions below

0
On

These options refer to the file names and line numbers that are part of a stack trace. The names for classes, methods, etc. are still obfuscated. Firebase can use your mapping file to translate these obfuscated names to their original names.

In case you need to preserve the names of the classes, methods, etc. you can set up -keep rules to do so as documented here under "Keep Options": https://www.guardsquare.com/manual/configuration/usage

You can see the impact your configuration has on your source tree by using the ProGuard Playground.