1

我在我的应用程序中使用 ProGuard,问题是当用户向我的控制台报告一些问题并且由于“未知来源”而我无法准确解码它时。

这是堆栈跟踪的示例:

java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
at com.my.package.j.a(Unknown Source)
at com.a.a.c.c.j(Unknown Source)
at com.a.a.c.c.b(Unknown Source)
at com.a.a.c.e.run(Unknown Source)
at java.lang.Thread.run(Thread.java:856)

然后我使用这段代码来解码它:

./retrace.sh -verbose mapping.txt stacktrace.txt > out.txt

这是输出:

java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
at com.my.package.MyFragment$10.void output(int,java.lang.String)(Unknown Source)
at com.stericson.RootTools.execution.Shell.void readOutput()(Unknown Source)
at com.stericson.RootTools.execution.Shell.void closeCustomShell()(Unknown Source)
                                           com.stericson.RootTools.execution.Shell startShell(int)
                                           void access$200(com.stericson.RootTools.execution.Shell)
at com.stericson.RootTools.execution.Shell$2.void run()(Unknown Source)
at java.lang.Thread.run(Thread.java:856)

它只在发生错误时显示片段的名称,但我还需要确切的行和方法。

4

1 回答 1

2

你的问题实际上有两个部分。

1)为什么你错过了线路信息?

您在混淆过程中删除了行信息。您的 proguard.cfg 中需要以下规则

-renamesourcefileattribute MyApplication
-keepattributes SourceFile,LineNumberTable

在此处查找追溯行号的详细信息:http: //proguard.sourceforge.net/manual/retrace/examples.html#with

2)为什么在你的例子中缺少一些方法/类名

com.my.package.MyFragment$10.void

这是因为 $10 很可能是一个匿名类声明,在编译和随后的混淆过程中会被区别对待。第一个简单的解决方案当然是摆脱匿名声明并在某处声明它。另一种解决方案是将以下行再次添加到您的 proguard.cfg

-keepattributes EnclosingMethod

这当然不会再次删除某些信息,并且会减少您的混淆。

于 2015-08-24T12:56:43.213 回答