-1

Before Proguard with:

Throwable().getStackTrace()[0].getLineNumber();

I got:

482

After Proguard I got:

41

Which is obviously wrong.

Here is the tested rules to solve this problem :

-keep class java.lang.StackElement
-keepattributes StackTraceElement
-keepattributes SourceFile,LineNumberTable
-keepattributes Signature
-keepattributes InnerClasses,EnclosingMethod
-keepattributes getStackTrace

But it doesn't work. Is there any specific rules to let this piece of code work properly ?

Community
  • 1
  • 1
Pensée Absurde
  • 1,315
  • 1
  • 14
  • 20

1 Answers1

0

According to the manual, you need to do this:

-renamesourcefileattribute SourceFile    
-keepattributes SourceFile,LineNumberTable

and you need to use -printmapping to save the mappings so that you can then decode the obfuscated stacktraces.

I should point out that references to classes and methods in the standard class library will always be retained since they are needed when your code is loaded. Therefore this "-keep" is superfluous:

-keep class java.lang.StackElement

And you are also telling Proguard to keep attributes called "StackTraceElement" and "getStackTrace" which don't exist. The list of supported attributes is documented here

See also:

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216