Annotated. Where a claim in the chapter rests on a source, the source is named here with what it was used for.
On citation discipline. R8 is not part of AOSP — it is a separate Google project shipped as a build tool inside the Android SDK. There is no frameworks/base path for its algorithms, and this chapter does not invent one. AOSP paths below are cited for the formats and runtime behaviour R8's output must satisfy, which genuinely do live in the platform tree.
"Shrink, obfuscate, and optimize your app" — developer.android.com/build/shrink-code
The minifyEnabled / isMinifyEnabled surface, android.enableR8.fullMode, and the documented location of mapping.txt and its siblings under build/outputs/mapping/<variant>/
The 65,536 method-reference limit that makes shrinking load-bearing rather than cosmetic
Android Studio "Retrace"/deobfuscation docs
The intended workflow for mapping.txt — useful context for arguing what its unintended distribution means
3. Kotlin metadata — the algorithms this chapter ports¶
The extractor in scripts/kotlin-metadata-recover.py is a port of these files, not a guess at the format. Each is worth citing precisely because getting any one of them slightly wrong produces plausible-looking wrong names.
Source (in github.com/JetBrains/kotlin)
Defines
.../metadata/jvm/deserialization/BitEncoding.java
decodeBytes, decode7to8, addModuloByte, and the (char) -1 8-to-7 mode marker
.../metadata/jvm/deserialization/utfEncoding.kt
UTF8_MODE_MARKER (U+0000), bytesToStrings, stringsToBytes — the modern default encoding
The supported library for reading this data on the JVM. Use it where a JVM dependency is acceptable; this chapter ships a dependency-free Python decoder because the field use case is a jump box with nothing installed
Anti-tampering and obfuscation appropriate to the threat model
The control minifyEnabled true with reviewed rules implements
MASVS-RESILIENCE-4
Measures that impede comprehension
Identifier renaming, inlining, class merging
MASVS-CODE-4
Release-mode build with appropriate settings
minifyEnabled, debuggable false, no mapping file shipped
OWASP MASTG, resilience testing group
Procedures for determining whether and how far an app is obfuscated
The measurement discipline in §8.4 — measure the app's own package, not the APK average
OWASP MASVS v2 overview — mas.owasp.org
The framing that resilience controls are graduated and threat-model-dependent
The severity argument in §5.7: resilience is not pass/fail, which is why "not obfuscated" is not automatically a finding
No CVE is cited in this chapter. Obfuscation weaknesses and mapping-file disclosures are configuration and process failures, not memory-safety or logic vulnerabilities, and they are not assigned CVE identifiers. Inventing one would be worse than citing none.
Google I/O and Android Dev Summit sessions on R8 and app size (Android Developers channel)
The Android tools team explaining the shrinking and optimisation model in their own terms — particularly useful for understanding why full mode reads rules narrowly
The ProGuard manual (Guardsquare)
Still the clearest exposition of the keep-rules language R8 inherited. Chapter 41 owns this material; read the manual when you need rule syntax rather than R8 semantics
Guardsquare's DexGuard material
Vendor documentation, so read it critically — but it is explicit about what R8 does not provide (string encryption, control-flow obfuscation), which is exactly the §6.4 boundary
Recorded separately so a later reader can tell evidence from documentation. All of it is reproducible with examples/build-r8-demo.sh and examples/build-ctf.sh.
Claim
How it was established
R8 8.6.2-dev lives in build-tools/35.0.1/lib/d8.jar; D8 and R8 share a build hash
--version on both main classes
Full mode output 5,324 bytes vs compat 13,956 from identical input
Four R8 runs over one Kotlin source
Full mode: 9 classes in the DEX, 4 of them R8-invented, from 11 declared source types
dexdump -f plus the mapping file
R8 strips kotlin.Metadata by default in both modes
Two builds with baseline rules; annotation absent from the DEX string table
-keepattributes *Annotation* does not preserve it
Compat build with that directive present; annotation still absent
When kotlin.Metadata is kept and classes are renamed, R8 rewrites the payload
Two builds with -keep class kotlin.Metadata + -keep,allowobfuscation; class and function names came back obfuscated
Kotlin property names survive that rewriting
Same builds: subscriberId, hardwareId, auditTrail, PEPPER, VAULT_FORMAT_VERSION recovered with their renamed JVM field and getter
Decoder correctness
Decoded kotlin.Metadata's own class, recovering data1/data2 behind getters d1()/d2(); then zero decode failures across 19 APKs and 316,000+ classes
k=3 payload is a bare ProtoBuf.Function; k=4d1 is unencoded plain part names
Both found as decode failures on real APKs and fixed
The empty-shell state exists
One corpus app: 1,393 classes with the annotation and every element absent
Corpus distribution: 10 of 19 APKs had no metadata; 0 yielded wholesale recovery
The census in §5.6
Best-case real recovery: 87 property + 24 function names across 132 renamed classes
Obfuscation as a subject: the technique taxonomy, string encryption, control-flow flattening, packers, the deobfuscation methodology
40 cites this chapter for kotlin.Metadata and for R8's synthetic artefacts. §5.6 here offers a measured refinement of 40's "frequently not stripped … wholesale" claim
This chapter uses keep rules and tabulates their effects on R8's phases; it does not teach the syntax. Referenced by name rather than by link because the file does not exist yet
Reading decompiled output; loading mapping.txt into jadx (-Prename-mappings.format=PROGUARD_FILE); the kotlin-metadata plugin; the artefact table in its §6.1
56 owns what your decompiler does with a mapping; this chapter owns the file format and what it discloses before you load it anywhere