Status Update
Comments
ri...@google.com <ri...@google.com> #2
Input sizes are the same:
$ unzip -d /tmp/8.1 ~/Downloads/r8_8_1_dump.zip > /dev/null
$ unzip -d /tmp/8.3 ~/Downloads/r8_8_3_dump.zip > /dev/null
$ ls -l /tmp/8.1
total 946048
-rw-r--r--@ 1 ricow wheel 407 Jan 1 1970 build.properties
-rw-r--r--@ 1 ricow wheel 22 Jan 1 1970 classpath.jar
-rw-r--r--@ 1 ricow wheel 5292598 Jan 1 1970 library.jar
-rw-r--r--@ 1 ricow wheel 460932086 Jan 1 1970 program.jar
-rw-r--r--@ 1 ricow wheel 1874319 Jan 1 1970 proguard.config
-rw-r--r--@ 1 ricow wheel 26 Jan 1 1970 r8-version
-rw-r--r--@ 1 ricow wheel 6902099 Jan 1 1970 startup-profile-1.txt
$ ls -l /tmp/8.3
total 928896
-rw-r--r--@ 1 ricow wheel 407 Jan 1 1970 build.properties
-rw-r--r--@ 1 ricow wheel 22 Jan 1 1970 classpath.jar
-rw-r--r--@ 1 ricow wheel 5292598 Jan 1 1970 library.jar
-rw-r--r--@ 1 ricow wheel 460932086 Jan 1 1970 program.jar
-rw-r--r--@ 1 ricow wheel 1874319 Jan 1 1970 proguard.config
-rw-r--r--@ 1 ricow wheel 26 Jan 1 1970 r8-version
-rw-r--r--@ 1 ricow wheel 6902099 Jan 1 1970 startup-profile-1.txt
Marker
$ tools/extractmarker.py --no-build ~/Downloads/r8_8_3.apk
/Users/ricow/Downloads/r8_8_3.apk: ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":21,"pg-map-id":"9840a01","r8-mode":"full","sha-1":"engineering","version":"8.3.21"}
/Users/ricow/Downloads/r8_8_3.apk: ~~R8{"compilation-mode":"release","has-checksums":false,"pg-map-id":"1c326f6","r8-mode":"compatibility","version":"2.2.64"}
/Users/ricow/Downloads/r8_8_3.apk: ~~R8{"compilation-mode":"release","has-checksums":false,"pg-map-id":"e8a35cb","r8-mode":"compatibility","version":"2.2.71"}
/Users/ricow/Downloads/r8_8_3.apk: ~~R8{"compilation-mode":"release","pg-map-id":"91046de","version":"1.5.68"}
$ tools/extractmarker.py --no-build ~/Downloads/r8_8_1.apk
Running: /Users/ricow/src/r8/third_party/openjdk/jdk-11/osx/Contents/Home/bin/java -ea -jar /Users/ricow/src/r8/build/libs/r8.jar extractmarker /Users/ricow/Downloads/r8_8_1.apk
/Users/ricow/Downloads/r8_8_1.apk: ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":21,"pg-map-id":"bdf8d82","r8-mode":"full","sha-1":"engineering","version":"8.1.71"}
/Users/ricow/Downloads/r8_8_1.apk: ~~R8{"compilation-mode":"release","has-checksums":false,"pg-map-id":"1c326f6","r8-mode":"compatibility","version":"2.2.64"}
/Users/ricow/Downloads/r8_8_1.apk: ~~R8{"compilation-mode":"release","has-checksums":false,"pg-map-id":"e8a35cb","r8-mode":"compatibility","version":"2.2.71"}
/Users/ricow/Downloads/r8_8_1.apk: ~~R8{"compilation-mode":"release","pg-map-id":"91046de","version":"1.5.68"}
DexSegments:
$ tools/dexsegments.py --no-build ~/Downloads/r8_8_1.apk
Segments in dex application (name: size / items):
- EncodedArrays: 6312 / 472
- Header: 896 / 8
- DebugInfo: 329540 / 7379
- Fields: 3693232 / 461654
- AnnotationSetRefs: 1920 / 115
- Strings: 1613108 / 403277
- Maps: 1748 / 8
- Protos: 1776720 / 148060
- Methods: 3717728 / 464716
- Types: 746772 / 186693
- StringData: 8466179 / 403277
- ClassData: 3604781 / 75381
- TypeLists: 1301662 / 104814 (TypeItems: 882406 / 441203)
- AnnotationsDirectory: 407696 / 10553
- Annotation: 427094 / 25580
- AnnotationSets: 211192 / 23751
- ClassDefs: 2572992 / 80406
- Code: 39404636 / 316871
$ tools/dexsegments.py --no-build ~/Downloads/r8_8_3.apk
Segments in dex application (name: size / items):
- EncodedArrays: 6371 / 475
- Header: 1008 / 9
- DebugInfo: 272115 / 3317
- Fields: 4113048 / 514131
- AnnotationSetRefs: 1960 / 118
- Strings: 1799220 / 449805
- Maps: 1968 / 9
- Protos: 1805376 / 150448
- Methods: 4376480 / 547060
- Types: 941140 / 235285
- StringData: 8704261 / 449805
- ClassData: 5169936 / 141183
- TypeLists: 1318242 / 111871 (TypeItems: 870758 / 435379)
- AnnotationsDirectory: 407464 / 10546
- Annotation: 431122 / 25851
- AnnotationSets: 213192 / 24001
- ClassDefs: 4683808 / 146369
- Code: 39785417 / 425116
From a size perspective, the code section did not grow that much, but we have way more code objects and methods
Dex file distributsion:
$ zipinfo ~/Downloads/r8_8_1.apk | grep classes
-rw---- 2.0 fat 6385348 bl defN 10-Jan-01 00:00 classes.dex
-rw---- 2.0 fat 8574892 bl defN 10-Jan-01 00:00 classes2.dex
-rw---- 2.0 fat 8778548 bl defN 10-Jan-01 00:00 classes3.dex
-rw---- 2.0 fat 9313912 bl defN 10-Jan-01 00:00 classes4.dex
-rw---- 2.0 fat 8945540 bl defN 10-Jan-01 00:00 classes5.dex
-rw---- 2.0 fat 8824588 bl defN 10-Jan-01 00:00 classes6.dex
-rw---- 2.0 fat 7379332 bl defN 10-Jan-01 00:00 classes7.dex
-rw---- 2.0 fat 10082048 bl defN 10-Jan-01 00:00 classes8.dex
$ zipinfo ~/Downloads/r8_8_3.apk | grep classes
-rw---- 2.0 fat 6205352 bl defN 10-Jan-01 00:00 classes.dex
-rw---- 2.0 fat 8579808 bl defN 10-Jan-01 00:00 classes2.dex
-rw---- 2.0 fat 8134600 bl defN 10-Jan-01 00:00 classes3.dex
-rw---- 2.0 fat 9127084 bl defN 10-Jan-01 00:00 classes4.dex
-rw---- 2.0 fat 8216176 bl defN 10-Jan-01 00:00 classes5.dex
-rw---- 2.0 fat 8466532 bl defN 10-Jan-01 00:00 classes6.dex
-rw---- 2.0 fat 8535776 bl defN 10-Jan-01 00:00 classes7.dex
-rw---- 2.0 fat 8509564 bl defN 10-Jan-01 00:00 classes8.dex
-rw---- 2.0 fat 8257236 bl defN 10-Jan-01 00:00 classes9.dex
ze...@google.com <ze...@google.com> #5
FYI, we have a few ideas to mitigate this. Assigning to Rico who is currently testing solutions.
ch...@google.com <ch...@google.com>
ap...@google.com <ap...@google.com> #6
Branch: main
commit 43b783f9b8ddc15ff7bd048619dd502650e178fd
Author: Rico Wind <ricow@google.com>
Date: Tue Dec 19 09:17:31 2023
Add test illustrating pinning of unrelated classes for keep patterns
In all cases specified, A should not be pinned (illustrated by the
baseline of not using if - or no rule at all)
Bug:
Change-Id: Ie91c0ffdd13e692904ad701e8b4144a0ec6ed3b8
A src/test/java/com/android/tools/r8/shaking/ifrule/PinningStarPatternTest.java
ap...@google.com <ap...@google.com> #7
Branch: main
commit 932d25ce2620a04a06299dbe4e9916f9adeccb45
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Tue Dec 19 10:56:41 2023
Fix missing member rules in synthetic -neverclassinline rule
Bug:
Change-Id: I6783f9174507ce468f246613c1ae311745e6a06d
M src/main/java/com/android/tools/r8/shaking/IfRuleEvaluator.java
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
A src/test/java/com/android/tools/r8/shaking/ifrule/AllowHorizontalClassMergingWithIfRuleTest.java
M src/test/java/com/android/tools/r8/shaking/ifrule/PinningStarPatternTest.java
ap...@google.com <ap...@google.com> #8
Branch: main
commit 0c21f1bbd071a6eaba2217d2d4dd6b34089912fe
Author: Rico Wind <ricow@google.com>
Date: Tue Dec 19 13:26:57 2023
Don't soft pin everything when doing -if class * rules
This only solves the problem for -if class * SUBSEQUENT, not the cases
where the conditional contains member specifications.
Bug:
Change-Id: Ie59e96669098f467303df8f5e6dbfdd71070c986
M src/main/java/com/android/tools/r8/shaking/IfRuleEvaluator.java
M src/main/java/com/android/tools/r8/shaking/ProguardAccessFlags.java
M src/main/java/com/android/tools/r8/shaking/ProguardConfigurationRule.java
M src/main/java/com/android/tools/r8/shaking/ProguardTypeMatcher.java
M src/test/java/com/android/tools/r8/shaking/ifrule/PinningStarPatternTest.java
ap...@google.com <ap...@google.com> #9
Branch: main
commit 6045845dc5bc9b37240b32d13a9146060d502789
Author: Rico Wind <ricow@google.com>
Date: Tue Dec 19 14:52:21 2023
Fix keep annotated member test
We now (correctly) keep the same classes in both cases
Bug:
Change-Id: Ib01a3bae77c5e7aa8a253a5dcf0da7bef9191a0b
M src/test/java/com/android/tools/r8/shaking/KeepAnnotatedMemberTest.java
ap...@google.com <ap...@google.com> #10
Branch: 8.3
commit 435dc09d6eeaaac3a8ebf0909912708003548139
Author: Rico Wind <ricow@google.com>
Date: Thu Dec 21 10:25:41 2023
Don't soft pin everything when doing -if class * rules
This only solves the problem for -if class * SUBSEQUENT, not the cases
where the conditional contains member specifications.
Bug:
Change-Id: Ie59e96669098f467303df8f5e6dbfdd71070c986
M src/main/java/com/android/tools/r8/shaking/IfRuleEvaluator.java
M src/main/java/com/android/tools/r8/shaking/ProguardAccessFlags.java
M src/main/java/com/android/tools/r8/shaking/ProguardConfigurationRule.java
M src/main/java/com/android/tools/r8/shaking/ProguardTypeMatcher.java
M src/test/java/com/android/tools/r8/shaking/ifrule/PinningStarPatternTest.java
ap...@google.com <ap...@google.com> #11
Branch: 8.3
commit 491ecadca31501de39b1b49b16f814811d2b43d7
Author: Rico Wind <ricow@google.com>
Date: Thu Dec 21 10:25:51 2023
Fix keep annotated member test
We now (correctly) keep the same classes in both cases
Bug:
Change-Id: Ib01a3bae77c5e7aa8a253a5dcf0da7bef9191a0b
M src/test/java/com/android/tools/r8/shaking/KeepAnnotatedMemberTest.java
ap...@google.com <ap...@google.com> #12
Branch: 8.3
commit 2c66c19e04464f5b45de24a3cdb405730437ed6a
Author: Rico Wind <ricow@google.com>
Date: Thu Dec 21 10:26:02 2023
Version 8.3.25
Bug:
Change-Id: I8e8f9eeddfeec790fc5818c9705bdcfa53fbbc6f
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #13
Branch: 8.3
commit d0e4181f6738d5faa5e8bf924533f579c18c9e13
Author: Rico Wind <ricow@google.com>
Date: Thu Dec 21 10:24:55 2023
Add test illustrating pinning of unrelated classes for keep patterns
In all cases specified, A should not be pinned (illustrated by the
baseline of not using if - or no rule at all)
Bug:
Change-Id: Ie91c0ffdd13e692904ad701e8b4144a0ec6ed3b8
A src/test/java/com/android/tools/r8/shaking/ifrule/PinningStarPatternTest.java
ap...@google.com <ap...@google.com> #14
Branch: 8.3
commit 0642fe3e3fd54de4e0d355317f55d4ae3e529566
Author: Rico Wind <ricow@google.com>
Date: Thu Dec 21 10:25:20 2023
Fix missing member rules in synthetic -neverclassinline rule
Bug:
Change-Id: I6783f9174507ce468f246613c1ae311745e6a06d
M src/main/java/com/android/tools/r8/shaking/IfRuleEvaluator.java
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
A src/test/java/com/android/tools/r8/shaking/ifrule/AllowHorizontalClassMergingWithIfRuleTest.java
M src/test/java/com/android/tools/r8/shaking/ifrule/PinningStarPatternTest.java
ri...@google.com <ri...@google.com> #15
Ben: if you take 8.3.25 and change:
-if class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-keepclasseswithmembers,allowobfuscation class <1> {
<init>(...);
}
to
-if class *
-keepclasseswithmembers,allowobfuscation class <1> {
@com.google.gson.annotations.SerializedName <fields>;
<init>(...);
}
You should be back below 8.1 sizes as a work around
The current fixes are for not pinning on -if class *, and also not with member specifications, but the annotation <fields> is somehow tripping us up (and does not easily reproduce with a simple example) I still need to figure out why that is, the size differences are pretty massive
ri...@google.com <ri...@google.com> #17
re #16: Not sure I follow, in what case would the first keep rule keep more than the second?
br...@snapchat.com <br...@snapchat.com> #18
Iirc, The issue we ran into using the rule you suggested was that we were using the type in a generic for Gson deserialization but never referencing the type directly. so the type would be erased in the generic to Object leading to the Gson code to crash.
Morten suggested the rule we have now which somehow ensures the type wasn't removed. The rule is quite complex so I'm not exactly sure why it works better. I think there's a test case that captures this behavior I believe
sg...@google.com <sg...@google.com> #19
Benjamin is right that
-if class *
-keepclasseswithmembers,allowshrinking,allowobfuscation class <1> {
<init>(...);
@com.google.gson.annotations.SerializedName <fields>;
}
require that both at least one <init>
and a @com.google.gson.annotations.SerializedName
annotated field is present, whereas the other will keep the <init>
's for all classes with a @com.google.gson.annotations.SerializedName
annotated field.
Note that you should probably change <init>(...)
to <init>()
to match the
ap...@google.com <ap...@google.com> #20
Branch: main
commit 17024bf79ef3ea7a81018e3bd7b67358e328c3d3
Author: Rico Wind <ricow@google.com>
Date: Fri Dec 22 11:04:46 2023
Add tests illustrating star pattern conditional keep issue with inlining
In the case where we have a simple method that we inline we don't keep the specified constructor
Only two cases in ConditionalRuleOnMemberWithKeepInitTest show the wrong behaviour.
For fields and simple value return we correctly keep the constructor and class
Bug: 316100042
Change-Id: I1cfd6443d0406451b4bfed0628b86c083d7fa8c3
A src/test/java/com/android/tools/r8/shaking/ifrule/ConditionalRuleOnMemberFieldWithKeepInitTest.java
A src/test/java/com/android/tools/r8/shaking/ifrule/ConditionalRuleOnMemberWithKeepInitSimpleInlineTest.java
A src/test/java/com/android/tools/r8/shaking/ifrule/ConditionalRuleOnMemberWithKeepInitTest.java
ch...@google.com <ch...@google.com> #21
It seems we mark 184,827 classes as ineligible for class merging due to -if
rules. Many of these classes are completely unrelated to gson (e.g., androidx.annotation.Keep
). I will try to diagnose why these classes are being marked as ineligible.
ap...@google.com <ap...@google.com> #22
Branch: main
commit b1cff385b38d81de3d1d0e72d4f7909287ed69bd
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 09:39:24 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
ap...@google.com <ap...@google.com> #23
Branch: main
commit a5e7061f4a2f921ac43cc0346214a6ea48d8d569
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Thu Jan 04 20:47:00 2024
Support for writing classes with no horizontal class merging
Bug:
Change-Id: Ibe423ea333c9fe39dc8adb3c99a14acd456aa5cc
M src/main/java/com/android/tools/r8/shaking/KeepInfoCollection.java
ap...@google.com <ap...@google.com> #24
Branch: 8.0
commit 2a22e5f13cf41a884eaaecb35ce95e481181491d
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:50:02 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
ap...@google.com <ap...@google.com> #25
Branch: 8.0
commit 2580e83d60200be531665ea79cc9f2e801dc7611
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:50:12 2024
Version 8.0.73
Bug:
Change-Id: I85b39889751befda6389d93ca94877a0de44e097
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #26
Branch: 8.1
commit fd78a229f564edac5c45b439175ebf735beedf19
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:49:29 2024
Version 8.1.76
Bug:
Change-Id: I81c5552c52710dfbef0df6210840b522b449733d
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #27
Branch: 8.1
commit 147f78856f224d82adff82724e1af1cc9cb6e7af
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:49:17 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
ap...@google.com <ap...@google.com> #28
Branch: 8.2
commit 7d8f81c4b3df410491209d8fb289a09182c7e53c
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:46:29 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
ap...@google.com <ap...@google.com> #29
Branch: 8.2
commit f917b7eb61e4642ff0d71965e7dd6bc908b200a7
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:48:09 2024
Version 8.2.44
Bug:
Change-Id: I189134160bfdd43adc5e8f632ef34fff7b4b6527
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #30
Branch: 8.3
commit a0d9ae1d9dfa9709a862914e4ca2a96f9fd4cbf1
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:45:21 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
ap...@google.com <ap...@google.com> #31
Branch: 8.3
commit b6dca00a5c0b171213cdf2cfec732b34494c7395
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:45:33 2024
Version 8.3.28
Bug:
Change-Id: I0fb14fefa0ea0e36ad79eabc57626fbf09bb7015
M src/main/java/com/android/tools/r8/Version.java
ap...@google.com <ap...@google.com> #32
Branch: 8.0
commit 2a22e5f13cf41a884eaaecb35ce95e481181491d
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:50:02 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
ap...@google.com <ap...@google.com> #33
Branch: 8.1
commit 147f78856f224d82adff82724e1af1cc9cb6e7af
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:49:17 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
ap...@google.com <ap...@google.com> #34
Branch: 8.2
commit 7d8f81c4b3df410491209d8fb289a09182c7e53c
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:46:29 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
ap...@google.com <ap...@google.com> #35
Branch: 8.0
commit 2a22e5f13cf41a884eaaecb35ce95e481181491d
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:50:02 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
ap...@google.com <ap...@google.com> #36
Branch: 8.1
commit 147f78856f224d82adff82724e1af1cc9cb6e7af
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:49:17 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
ch...@google.com <ch...@google.com> #37
Ben, can you check if updating to 8.3.28 resolves the issue?
You may still see a small regression, since -if
rules correctly, but hopefully not anywhere near the regression you reported here.
ap...@google.com <ap...@google.com> #38
Branch: 8.0
commit 2a22e5f13cf41a884eaaecb35ce95e481181491d
Author: Christoffer Quist Adamsen <christofferqa@google.com>
Date: Fri Jan 05 10:50:02 2024
Do not filter member rules in synthetic -nohorizontalclassmerging rule
Bug:
Change-Id: I4e0e83b6350b60cf295c46475cb81c9990881ca8
M src/main/java/com/android/tools/r8/shaking/ProguardIfRule.java
br...@snapchat.com <br...@snapchat.com> #39
With R8 8.3.28, we observe app size reduced by 90KB.
br...@snapchat.com <br...@snapchat.com> #40
Btw, Soren when I replaced our Gson rules with the rules from upstream, our app size increases by 600KB.
Here are the rules we are using for GSON:
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep,allowobfuscation class * implements com.google.gson.TypeAdapterFactory
-keep,allowobfuscation class * implements com.google.gson.JsonSerializer
-keep,allowobfuscation class * implements com.google.gson.JsonDeserializer
# @SerializedName annotation
-keep @interface com.google.gson.annotations.SerializedName { *; }
# Do not strip any field that is annotated with @SerializedName
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
# Ensure init methods are preserved if class has @SerializedName annotations
# Ref: https://partnerissuetracker.corp.google.com/issues/280658459#comment4
-if class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-keepclasseswithmembers,allowobfuscation class <1> {
<init>(...);
}
-if class *
-keepclasseswithmembers,allowshrinking,allowobfuscation class <1> {
@com.google.gson.annotations.SerializedName <fields>;
}
##---------------End: proguard configuration for Gson ----------
Note, when doing this comparison I didn't switch the <init>(...)
with <init>()
yet.
ch...@google.com <ch...@google.com> #41
Thanks for the update. I will mark this as fixed then.
an...@google.com <an...@google.com> #42
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Iguana | 2023.2.1 Beta 2
- Android Gradle Plugin 8.3.0-beta02
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
an...@google.com <an...@google.com> #43
The fixes for this issue are now also available in:
- Android Studio Hedgehog | 2023.1.1 Patch 2
- Android Gradle Plugin 8.2.2
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
so...@google.com <so...@google.com> #44
Comment added by automation: A postmortem has been automatically requested for this issue. Please author a postmortem on IRM. See go/android-postmortem-guidance for more context and details, including how to handle the case when this issue does not need a postmortem. If you have any questions not answered by go/android-postmortem-guidance, please email android-hygiene-tpm@, instead of reassigning the fixed bug. Thank you.
an...@google.com <an...@google.com> #45
Further fixes for this issue are now available in:
- Android Studio Iguana | 2023.2.1 RC 1
- Android Gradle Plugin 8.3.0-rc01
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Description
Background
While upgrading from 8.1.56 to R8 8.3.21 we are observing an ~1.5MB app size increase.
Note, I tried R8 8.2.24 a while back and it was only ~70KB decrease (so we skipped that version) so the regression would be something introduced after that.
I'll share the compiler dumps over email.