Search code examples
androidandroid-gradle-pluginandroid-r8

Enabling minification in debuggable builds for agp >=8.4


Android Gradle Plugin 8.4.0 now displays the following warning/error:

WARNING: BuildType 'r8debug' is both debuggable and has 'isMinifyEnabled' set to true.
Debuggable builds are no longer name minified and all code optimizations and obfuscation will be disabled.
  • Why does it do that?
  • How do I tell it to minify my app anyway?

The r8debug build type is specifically for debugging issues with r8.
Obfuscation is disabled for all my builds so debugging did/will work.


Solution

  • The warning is mainly for information. We changed the R8 behaviour at some point to always turn off obfuscation and optimization for debug builds independent of -dontobfuscate and -dontoptimize. We then got bug reports from developers wanting to have a debug build with obfuscation and optimization enabled, but that is no longer possible, and this warning is trying to say exactly that.

    You mention that you already had obfuscation disabled for debugability and now you also get optimization turned off for even better debugability (shrinking to remove unused code is still enabled).

    In your case you can just ignore the warning.