Mobile apps

What is R8 and code obfuscation?

R8 is the Android build tool that removes unused code, optimizes what remains and renames classes and methods to short meaningless names. The result is a smaller app that is harder, though not impossible, to reverse engineer.

What it does

Shrinking drops code that is never reached. Optimization simplifies it. Obfuscation renames identifiers so a decompiled app shows names like a.b.c instead of PaymentValidator. Together they cut app size and slow casual copying.

What it breaks

Anything found by name at runtime, such as reflection, JSON mapping libraries or some SDKs, can fail after renaming. Developers add keep rules in a proguard-rules file to protect those classes. The classic symptom: the app works in debug and crashes in release.

Mapping files

R8 produces a mapping file linking scrambled names back to real ones. Upload it to Google Play or your crash tool, or crash reports will be unreadable.

Limits

Obfuscation is not encryption. Never ship secrets in the app expecting it to hide them; keep keys and business rules on the server.

Questions, answered

R8 replaced ProGuard as the default and reads the same rules files.

It slows it down. Real protection needs server-side checks and integrity services.

By the Stegnor team · Updated