Fixed
Status Update
Comments
im...@google.com <im...@google.com> #2
There's no need to extract it - we can just consume the R.txt instead, which already contains this information: type + name + ID of each resource.
im...@google.com <im...@google.com> #3
So this is a 2 step bug:
1) make the resource shrinker (ShrinkResourcesTask, ResourceUsageAnalyzer) use R.txt instead of the (light) R classes. They contain the same information, and we already have the R.txt parsers in SymbolIo, so it should be fairly straightforward (famous last words...:) )
2) Stop "keep"ing the R classes - remove the keep rule mentioned in comment #1
1) make the resource shrinker (ShrinkResourcesTask, ResourceUsageAnalyzer) use R.txt instead of the (light) R classes. They contain the same information, and we already have the R.txt parsers in SymbolIo, so it should be fairly straightforward (famous last words...:) )
2) Stop "keep"ing the R classes - remove the keep rule mentioned in
lu...@google.com <lu...@google.com>
lu...@google.com <lu...@google.com> #4
Update:
- ResourceUsageAnalyzer now supports R.txt files: ag/9652255
- Adding design doc for reference: go/res-shrink-r-txt-usage
- This feature is controled via ENABLE_R_TXT_RESOURCE_SHRINKING boolean option
Remaining work:
lu...@google.com <lu...@google.com> #5
Total build time when ResourceUsageAnalyzer consumes R.txt appears nominal compared to consuming R classes. Red line indicates android.enableRTxtResourceShrinking flag is true and blue line indicates android.enableRTxtResourceShrinking flag is false.
lu...@google.com <lu...@google.com>
jr...@squareup.com <jr...@squareup.com> #6
In which version of AGP/R8 was this fixed?
lu...@google.com <lu...@google.com> #7
This issue is fixed in AS 4.1 Canary 5 [4.1.0.5] & D8 R8 version: 2.1.9-dev.
je...@gmail.com <je...@gmail.com> #8
Could it be that this broke library distribution? When I upgrade to 4.1 my R.txt only contains 0x0 for every resource
Description
-keepclassmembers class **.R$* {
public static <fields>;
}
This means that all fields in R class will be kept in the final APK. Considering these are not used in the code (they have been inlined), this is wasteful.
The only user of these constants is the resource shrinker, which uses R class to find all IDs, and it tries to match them with the int constants in the code. However, list of names + IDs can be extracted before shrinking runs, thus avoiding the need to keep R class fields.