ProGuard configs are easy to improve with agents
The less something in a project resembles regular code and the more it resembles configuration, the more likely everyone is to treat it carelessly. Understanding it is a separate, low-priority skill that most people lack.
In Android, this includes Gradle configs, CI setup, and even some magical DI framework like Dagger in the code. But ProGuard/R8 configs top my list of such things. 🪖
For non-Android developers: these are sets of rules that define how code is obfuscated, minified, and optimized after a build. How you write these configs affects how long the process takes, the app's stability, and its size. Your rules are also merged with rules from every dependency—a nightmare.
Honestly, I have never seen a proper setup because this is the embodiment of the saying “if it works, don't touch it.” It is a horribly inefficient and unpleasant situation. Change a few rules and something may break in obscure places, and you will learn about it far too late. You need regression testing and profiling.
And how wonderful it is that we live in a world with agents. R8 generates many artifacts during its run that describe how the mapping went. First, we establish a baseline, then have an agent double-check whether our rules duplicate rules pulled in transitively from libraries. It removes the redundant ones and uses scripts to see whether the artifacts have changed. Next, we push it to go through every remaining rule, try to narrow its scope, rewrite or delete it, and decompose the rules into groups. Then let it continue in a loop until there is still no impact on the baseline or the impact becomes clearly positive. The scary part is that, when necessary, it can even inspect libraries' AAR files or the final bundle to draw conclusions. We cannot do that ourselves—let's admit it.
In this case, we have a clear feedback loop that lets the agent verify it has not broken anything. It may seem like an obvious use case, but I still have moments of revelation when I notice an opportunity like this and put it into practice. The agent worked in the background for a couple of days: at the very least, it made the configs easier to maintain; at best, it also removed something redundant. And it did so while still letting us sleep soundly.