Safeguard
Developer Tools•

What are consumer ProGuard rules and why do libraries ship them?

Android libraries can ship consumer ProGuard rules that are appended to your app's shrinker config. Learn what that does and how to review the effect.

Safeguard Security Team
3 min read

Consumer ProGuard rules are shrinker rules that an Android library ships inside its AAR. When you add the library, the build appends them to your app's configuration, so you do not edit your own files. The effect can be that code you expected to be removed is kept.

How they work

The Android documentation says a library can include a proguard.txt and declare it with consumerProguardFiles in its Gradle configuration. When an app adds the library, those rules are added to the app's ProGuard configuration. The same page notes that if a library is part of a multi module build that produces an APK rather than an AAR, code shrinking should run on the consuming app module.

Why this touches security

Shrinking removes unused code, which shrinks the amount of library code that ships. A broad keep rule undoes that for the classes it matches. A vulnerable class that you assumed was stripped may remain in your release build.

This matters when you ask whether a vulnerable library is truly present. The answer depends on what your shrinker kept, not just what your build file lists. See if R8 removes unused library code, is my app still affected for the wider question.

What to review

ItemWhy
Broad keep rules for a whole packageKeeps everything in that package
Rules for reflectionMay keep classes reachable just by name
Rules from every libraryThey stack, so one loose rule affects the app

Steps

  1. Unzip the AAR and open proguard.txt if it exists.
  2. Search for rules that keep entire packages or all members.
  3. Build a release and compare the shrunk output with and without the library's rules, if you can.
  4. If a rule keeps more than needed, ask the maintainer, or add a narrower rule of your own where the build allows it.
  5. Record which libraries carry such rules.
  6. Re-check when you update the library, since rules can change between versions.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how knowing which code is actually reachable changes which findings matter.

Safeguard builds an SBOM and scans your dependencies for known vulnerabilities, and you can run a free scan at gold.safeguard.sh/scan to see what your own project pulls in.

Quick check

Do consumer rules apply automatically?

Yes. Per the Android documentation, the build appends them to your app's configuration when you add the library.

Does shrinking remove a vulnerable library for sure?

No. It removes unused code, and keep rules can retain classes. Check the release output.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.