Sentry plugin is an only blocker for us to start using R8 code shrinker.
Android Studio stable version 3.3 has been released with R8 under feature toggle. But next version of AS 3.4 is going to enable this by default. It would be very appreciated that until that this problem could be solved.
I'm very interested in this feature too. I'm ready to help with R8 support and have some experience in android gradle plugin. It would be great if someone from maintainers described the main issues with android r8.
From what I understood the R8 version bundled with AGP 3.3.0 should already emit a mapping file that has the same format as the ProGuard one (it only includes some comment lines at the top of the file).
Unfortunately I could not try that on my project yet, could you @audkar ?
Yes, R8 generates the mapping file. I'll be able to test sentry with r8 in a couple of weeks.
Just performed some tests on a simple Android project with AGP 3.3.0 and R8.
R8 has a built-in feature called "Line Number Optimization" which will remap methods' source line numbers to smaller values to shrink the bytecode as much as possible (the value emitted with .line bytecode instruction). LNO will be enabled when building a minified release type (source: https://issuetracker.google.com/issues/70776323#comment6)
When LNO is enabled, R8 will generate a mapping file that records the old line number range (os:oe) and the new line number range (ns:ne) with this format (accepted and understood by ProGuard 6.0.2 ReTrace tool):
ns:ne:_ _(_,_):os:oe -> _
e.g.
it.ninniuz.r8.R8Test -> it.ninniuz.r8.a:
1:1:void <init>():5:5 -> <init>
1:2:void testMethod():7:8 -> a
That means that an Exception originating at line 8 in it.ninniuz.r8.R8Test.testMethod will be reported as occurring at line 2 of method it.ninniuz.r8.a.a
As far as I can see the current version of rust-proguard does not understand this format and will very likely fail retracing a stacktrace from an Android app minified with the current version of R8 bundled with AGP 3.3.0.
@buckett do you think this can be addressed any time soon?
@ninniuz I'm a developer on this project and probably won't be fixing this myself. Did you mention the wrong person?
@ninniuz I'm a developer on this project and probably won't be fixing this myself. Did you mention the wrong person?
Yes, I wanted to mention @bretthoerner 馃槂
Have to loop in @mitsuhiko here for the Proguard server-side stuff, mostly because I'm actually out on paternity leave.
I'm curious though, without this LNO feature enabled can the existing R8 mapping file be uploaded to Sentry manually using the sentry-cli tool and does the desymbolification work? That'd be a good thing to figure out.
I'm curious though, without this LNO feature enabled can the existing R8 mapping file be uploaded to Sentry manually using the
sentry-clitool and does the desymbolification work? That'd be a good thing to figure out.
From this sentence in https://issuetracker.google.com/issues/70776323#comment6
If a map file is needed to understand stack traces, then line number optimization will also be turned on.
and from the relevant source code in https://r8.googlesource.com/r8/+/master/src/main/java/com/android/tools/r8/R8Command.java#673
I'd say LNO is turned off for release builds iff optimization and minification are both turned off.
If minification is turned off, though, there is no need for a mapping file since you won't have any obfuscated name in the resulting bytecode.
Apart from LNO, I think the R8 mapping file (when R8 is used in compat mode) is compatible with Proguard mapping file format, hence it should be possible to upload it with sentry-cli and desymbolification should work as-is.
(as a matter of fact, the current R8 mapping file, also with LNO on, is compatible with the latest Proguard retrace tool which uses this function in MappingReader)
This is coming shortly via @bruno-garcia
We've added support for R8. It's getting deployed to sentry.io now.
It also requires the latest version of the sentry-gradle-plugin and/or sentry-cli.
R8 support is in 1.7.20 thanks to @bruno-garcia
https://github.com/getsentry/sentry-java/releases/tag/v1.7.20
Most helpful comment
We've added support for R8. It's getting deployed to sentry.io now.
It also requires the latest version of the
sentry-gradle-pluginand/orsentry-cli.