-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update ProGuard default shrinking rules #2448
Changes from 1 commit
7fa9ef5
e384d4d
f60e17d
eea08d0
4c40a91
c34126b
af98d32
ac6e590
8d14f1a
743d529
3468700
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
# Keep class TypeToken (respectively its generic signature) if present | ||
-if class com.google.gson.reflect.TypeToken | ||
-keep,allowobfuscation class com.google.gson.reflect.TypeToken | ||
#-keep class com.google.gson.reflect.TypeToken { *; } | ||
|
||
# Keep any (anonymous) classes extending TypeToken | ||
-keep,allowobfuscation class * extends com.google.gson.reflect.TypeToken | ||
|
@@ -54,16 +55,19 @@ | |
<init>(); | ||
} | ||
|
||
# Keep fields annotated with @SerializedName for classes which are present. | ||
# Keep fields annotated with @SerializedName for classes which are referenced. | ||
# If classes with fields annotated with @SerializedName have a no-args | ||
# constructor keep that as well. | ||
# constructor keep that as well. Based on | ||
# https://issuetracker.google.com/issues/150189783#comment11. | ||
# See also https://github.com/google/gson/pull/2420#discussion_r1241813541 | ||
# for a more detailed explanation. | ||
-if class * | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least for R8 it does seem to make a difference: Unfortunately this is not covered by the tests yet; have created #2455 to add a test for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks also for the other points you raised, but unless sgjesse wants to address them here as well could you please create a separate GitHub issue or pull request? Otherwise the discussion on this pull request here might drift too far away from the original topic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed the rules to be two
|
||
-keepclasseswithmembers,allowobfuscation class <1> { | ||
@com.google.gson.annotations.SerializedName <fields>; | ||
} | ||
-if class * { | ||
@com.google.gson.annotations.SerializedName <fields>; | ||
} | ||
-keepclassmembers,allowobfuscation class <1> { | ||
-keepclassmembers,allowobfuscation,allowoptimization class <1> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought in #2448 (comment) you just explained that you intentionally removed (Or am I misunderstanding this?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This rule is only covering the no-args constructor ( |
||
<init>(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,5 @@ | |
-keepclassmembernames class com.example.ClassWithVersionAnnotations { | ||
<fields>; | ||
} | ||
|
||
-dontobfuscate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intentional? I think this should not be necessary and there were explicit rules which preserved names where needed for the tests. - -keepclassmembernames class com.example.NoSerializedNameMain$TestClassWithoutDefaultConstructor {
- <fields>;
- } There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this was all for some testing. These changes should not have been there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this commented line intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No removed.