R8 supports ProGuard-style obfuscation dictionary directives. You can use -obfuscationdictionary, -classobfuscationdictionary, and -packageobfuscationdictionary to influence generated names in release builds.
What an Obfuscation Dictionary Does
An obfuscation dictionary supplies candidate names for R8 when it renames methods, fields, classes, or packages. Instead of predictable names such as a, b, and c, the output can use custom words or Unicode confusable characters.
This does not make the app impossible to reverse engineer, but it can make decompiled output harder to read, search, and reason about.
Dictionary Directives
-obfuscationdictionary proguard-dic-homoglyph.txt
-classobfuscationdictionary proguard-dic-homoglyph.txt
-packageobfuscationdictionary proguard-dic-homoglyph.txt
Manual Workflow
- Choose a dictionary file with valid Java identifier characters.
- Place it beside your ProGuard rule file or use a stable relative path.
- Add one or more dictionary directives to
proguard-rules.pro. - Build the release variant with R8 enabled.
- Inspect
mapping.txtand decompiled output to confirm the dictionary is used. - Run release smoke tests to catch any unrelated keep-rule regressions.
Dictionary Options
| Strategy | Best For | Tradeoff |
|---|---|---|
| Minimal confusable | Lightweight visual confusion | Smaller name space. |
| Homoglyph | General-purpose Unicode confusion | Harder to inspect in some tools. |
| Greek or Cyrillic | Readable but non-ASCII output | May be easier to classify by script. |
| Ultimate | Large projects needing a large pool | More aggressive output. |
How ADB Pro Helps
R8 Assistant exposes dictionary management in the IDE and links dictionary selection with R8 configuration. The public ProGuard Dictionaries page provides preset dictionary files that can be downloaded and used directly.
FAQ
Does R8 still use ProGuard rule syntax?
Yes. Android projects commonly use ProGuard-compatible rule files even when R8 is the actual shrinker.
Can dictionaries replace keep rules?
No. Dictionaries only influence generated names. Keep rules are still required for runtime-sensitive classes and members.
How do I know whether a dictionary worked?
Check mapping.txt. If renamed classes or members use your dictionary characters, the directive is active.