lannyf
lannyf

Reputation: 11035

why it needs two proguard rule -keep for same class

In one app, saw these two in proguard rules used in same rule file.

-keep public class com.google.gson.**
-keep public class com.google.gson.** {public private protected *;}

first one has only class. second one brackets with some more details.

why it needs two rules? isnt the first one also apply to the class members?

Upvotes: 0

Views: 367

Answers (1)

TrueStory
TrueStory

Reputation: 582

The first option (-keep public class com.google.gson.**) will preserve the public class names in the package com.google.gson and all underlying packages but not their members.

With the second option, which is equivalent to -keep public class com.google.gson.** { *; } you will preserve the public class names together with their members. Commenting out the first -keep option should make no difference.

You can use the ProGuard Playground to see the effect of your ProGuard configuration on the classes inside your jar/apk. I created one already with these -keep options which you can open by clicking the link.

Upvotes: 2

Related Questions