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!
really works
but the example you posted is clear that code without reach by runtime (explicit code) will be erased, so if you doReflection API
you must addkeep class
andkeep names
for the classes only acessibles by other means. The best test would be activate it and test your app. – Comedienne