0

In order to run my application with Proguard, I need to add the following line to my Proguard.cfg:

-keep class android.support.** { *; }

Is this common practice to keep such classes? If not, how much is this line impacting Proguard optimization?

Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
Jim Layhey
  • 353
  • 5
  • 13
  • "In order to run my application with Proguard, I need to add the following line", — no you don't **need** to do such thing. Modern support library is already compatible with Proguard without it. In fact, using this line is an obvious indicator, that your Proguard config is incorrect. – user1643723 Apr 13 '18 at 10:54
  • @user1643723 I'm running the latest version of Proguard (Unmodified) and the latest version of the support library. What config do you suggest I look at? – Jim Layhey Apr 13 '18 at 20:58
  • My suggested config is described in https://stackoverflow.com/a/31508908/1643723. TL; DR: Rather than blacklisting Android Support Libraries, they should be white-listed (along with other libraries, that are known to support Proguard). – user1643723 Apr 14 '18 at 01:40

2 Answers2

1

Yes, this is somewhat common while setting up proguard rules for your project. The libraries are SDK materials that you do not need to obfuscate actually. However, you need not to obfuscate any third-party library unless its highly needed to obfuscate it. Because, in some cases, you do not know the interdependency of the classes inside the third-party library you are using. If you really have to obfuscate the third-party library code, then please go through the proguard-rules specification for that library as well. In case of obfuscating third-party libraries you might face RuntimeException in your application.

Keeping classes do not really have any impact in proguard optimization. You are just telling proguard that you want to keep the classes inside the com.android... package as they are without being obfuscated.

Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
  • 1
    do note that using keep will prevent Shrinking of your codes too. have a look at the link below to see the various directives available besides "keep class". https://jebware.com/blog/?p=418 – Angel Koh Apr 13 '18 at 03:57
0

Add with this progard :

-ignorewarnings -keep class * { public private *; }

here this prograd use to ignore warnings