且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何准确解码ProGuard的混淆代码?

更新时间:2023-12-03 23:45:04

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

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.