alwaystest / Blog

24 stars 2 forks source link

ProGuard assumenosideeffect 的局限 #66

Open alwaystest opened 7 years ago

alwaystest commented 7 years ago

ProGuard outputs

标签(空格分隔): Proguard


ProGuard outputs the following files after it runs:

dump.txt Describes the internal structure of all the class files in the .apk file mapping.txt Lists the mapping between the original and obfuscated class, method, and field names. This file is important when you receive a bug report from a release build, because it translates the obfuscated stack trace back to the original class, method, and member names. See Decoding Obfuscated Stack Traces for more information. seeds.txt Lists the classes and members that are not obfuscated usage.txt Lists the code that was stripped from the .apk


Explaining why classes and class members are being kept...
Printing usage to [/Users/eric/***/app/build/outputs/mapping/develop/release/usage.txt]...

xxx.xxx.DebugLog
  is invoked by    xxx.util.UIUtil: void someMethod(java.io.File) (983:989)
  is invoked by    xxx.util.UIUtil: void someMethod(android.content.Context,int,int) (911:980)
  is invoked by    xxx.TestActivity: void onClick(android.view.View) (175:208)
  is kept by a directive in the configuration.

xxx.util.UIUtil
  is invoked by xxx.CustomView: CustomView(android.content.Context,android.util.AttributeSet,int) (21:62)
  is kept by a directive in the configuration.

xxx.TestActivity
  is kept by a directive in the configuration.

所以即使开启了优化,并且声明删除DebugLog的规则,也会由于某些被Keep的方法调用到DebugLog而导致编译时删除DebugLog失败。