8

The auto-generated proguard-rules.pro has the following:

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

I have had this commented out for years and it worked perfectly until Android Studio 3.4 that uses R8 instead of ProGuard by default.

Let's use the following example:

 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
    at net.foo.anroid.Foo.wb.d(SourceFile:453)
    at net.foo.anroid.Foo.wb.a(SourceFile:213)
    at net.foo.anroid.Foo.wb.n(SourceFile:103)
    at net.foo.anroid.Foo.qa.run(Unknown Source:2)
    at java.lang.Thread.run(Thread.java:764)

The line numbers (e.g. 453, 213...) used to be the actual lines numbers in a java code source file when ProGuard was used, but they are not anymore with R8. Even using the officially suggested de-obfuscating tool ReTrace does not restore the original line numbers.

What does "-keepattributes SourceFile,LineNumberTable" do exactly?

4

0 回答 0