Published on · Guide
Broad keep rules: a compatibility fix can preserve clues
Reflection and dynamic behavior need careful keep rules. Preserving an entire package should not be the default fix.
Keep rules describe required behavior
Android explains that optimizers need additional information for dynamic uses such as reflection, and broad keep rules restrict optimization. Preserved names and types may also help an analyst. That exposure assessment is our inference, not an official security rating of every name.
Narrow rules without breaking the app
Review each rule's entry point, dependency, reason and regression test. Neither deleting necessary rules for an obfuscation percentage nor keeping everything after a crash is a sound strategy. Explicit registration may reduce dynamic-name dependencies; still test serialization, plugins, JNI and recovery.
Your checklist
- Record the source of every rule.
- Narrow patterns with corresponding tests.
- Separate compatibility failures from exposure changes.
Primary sources
- Android: About keep rules · Checked 2026-10-12