Is there a way to prevent Android app code shrinker R8 from changing line numbers?

This has been discussed from time to time on the R8 team, and we went with always optimizing line numbers for a number of reasons:

  • It saved in the area of 5% on the dex size
  • For release builds where optimizations like inlining are turned on retracing is needed anyway to expand the inlined frames
  • It is one less option in the testing matrix

Right now it is always turned off for debug builds, and for release builds when both -dontoptimize (implies no inlining) and -dontobfuscate are set in the configuration.

When you use retrace (remember to use the one from Proguard version 6 or later) you don't need to cut out the stacktrace, as retrace will pass non stack trace lines through unmodified.

There is currently no library to do this in the app, and as that requires the mapping file to be included in the app that defeats the purpose of making apks small.