The R8 official documentation says that to activate additional optimizations I must insert this in the gradle.properties
file:
android.enableR8.fullMode=true
The documentation says that in order to make the App to work I must set some keep rules but there aren't details on how it works and what actions it performs:
Because the additional optimizations make R8 behave differently from ProGuard, they may require you to include additional ProGuard rules to avoid runtime issues. For example, say that your code references a class through the Java Reflection API. By default, R8 assumes that you intend to examine and manipulate objects of that class at runtime—even if you code actually does not—and it automatically keeps the class and its static initializer.
However, when using “full mode”, R8 does not make this assumption and, if R8 asserts that your code otherwise never uses the class at runtime, it removes the class from your app’s final DEX. That is, if you want to keep the class and its static initializer, you need to include a keep rule in your rules file to do that.
The link to the FAQs suggested by the documentation says only this:
R8 full mode
In full mode, R8 performs more aggressive optimizations, meaning that additional ProGuard configuration rules may be required. This section highlights some common issues that have been seen when using full mode.
How does android.enableR8.fullMode
really work?
Thanks a lot!
The difference between full mode and compatibility mode is described in the R8 FAQ.
Note, if the keep rules for the program are complete in the sense that everything which is used by reflection is covered by a keep rule, then turning on android.enableR8.fullMode
should not cause issues. However, we often see configurations, where these (also not documented) conventions from Proguard are making the configuration work.