如何准确解码ProGuard的混淆代码? [英] How to decode ProGuard's obfuscated code precisely?

查看:241
本文介绍了如何准确解码ProGuard的混淆代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using ProGuard in my application and problem is when users report some problem to my console and I can't decode it precisely because of "Unknown source".

这是stacktrace的示例:

Here is example of stacktrace:

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)

然后我正在使用以下代码对其进行解码:

Then I am using this code to decode it:

./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)

仅在发生错误时显示Fragment的名称,但我还需要确切的行和方法.

推荐答案

您的问题实际上有两个部分.

Your question has actually two parts.

1)为什么您缺少线路信息?

1) Why are you missing the line information?

您要在混淆过程中删除线路信息.您需要在proguard.cfg中设置以下规则

You are removing the line information during obfuscation. You need the following rules in your proguard.cfg

-renamesourcefileattribute MyApplication
-keepattributes SourceFile,LineNumberTable

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

Find details for retracing line numbers here: http://proguard.sourceforge.net/manual/retrace/examples.html#with

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

2) Why is it missing some method/class name, in your example

com.my.package.MyFragment$10.void

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

This is because $10 is most likely an anonymous class declaration which will be treated differently during compiling and subsequent obfuscation. First easy solution is of course to get rid of the anonymous declaration and declare it somewhere. Another solution would be to add the following line again to your proguard.cfg

-keepattributes EnclosingMethod

这当然会再次不删除某些信息,并会减少您的困惑.

This of course will again not remove some information and will reduce your obfuscation.

这篇关于如何准确解码ProGuard的混淆代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆