Repository navigation
Obfuscate an allowlist of libraries in Play builds - #2282
Draft
mpretty-cyro wants to merge 1 commit into
Draft
mpretty-cyro wants to merge 1 commit into
mpretty-cyro wants to merge 1 commit into
Conversation
Play requires obfuscated DEX, and every build had obfuscation turned off. Play builds now rename AndroidX, Material, OkHttp/Okio and Glide. Everything else keeps its name, since it is reached by name from native code, Kryo-persisted jobs, reflection or ServiceLoader. The website, F-Droid and Huawei builds keep -dontobfuscate. R8's reported scores for playQa go from 0.0 / 84.8 / 85.8 to 49.6 / 87.0 / 87.9 (obfuscation / optimisation / shrinking). Crash traces from Play builds need the mapping file, which the AAB carries for Play Console.
mpretty-cyro
force-pushed
the
r8-obfuscation-allowlist
branch
from
December 3, 2026 04:52
543b4af to
9d8f565
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Google Play requires app bundles to reach at least 25% in each of R8's obfuscation, optimisation and shrinking scores by February 2027. Play Console reports this app's obfuscation as 0%, because every build has had
-dontobfuscatesince #1889. This turns obfuscation on for Play builds, limited to libraries that are safe to rename.What's renamed: AndroidX, Material, OkHttp/Okio and Glide. Everything else keeps its name, as before:
kotlin.Pair/kotlin.Triple), sqlcipher, conscrypt and WebRTC;The renamed libraries' own consumer rules already keep their by-name entry points: XML-inflated views and CoordinatorLayout behaviours, WorkManager workers and input mergers, startup initializers and Glide's generated module. Coil stays out because it finds its decoders through ServiceLoader, so a renaming fault there would fail silently.
Which builds: the
playflavour'srelease,releaseWithDebugMenu,qaandautomaticQaare obfuscated.website,fdroidandhuaweiaddproguard-dontobfuscate.proand stay unobfuscated in every build type.debugisn't minified.Scores: Play reads these from the
r8.jsonthat R8 writes into the bundle (BUNDLE-METADATA/com.android.tools/r8.json). Measured onplayQafrom the same commit:devDEX is 0.6 MB larger (15.26 → 15.84 MB): R8 can't merge a class whose name is kept, so slightly fewer classes are merged than under
-dontobfuscate. The universal APK grows 0.25%. R8 reports no warnings.Crash reports: AGP already puts
mapping.txtinto the AAB (BUNDLE-METADATA/com.android.tools.build.obfuscation/proguard.map), so Play Console deobfuscates Play crashes. Session class and method names in traces and exported logs stay readable without the mapping. Line numbers already needed it (r8-map-id-<id>:N), and the id names the exact mapping file. Frames inside the renamed libraries need the mapping.For traces from outside Play (exported logs, or play APKs installed from GitHub), the mapping is in the
app-play-release.aabthat the release script uploads to each GitHub release. It comes from the same R8 run as the play APKs:The trace's
r8-map-id-<id>should match the# pg_map_id:line at the top ofmapping.txt.Testing
testPlayDebugUnitTest: 461 tests pass.playQaon two emulators, no app errors:devbuild while offline: an image upload and five send jobs persisted by the old build resumed in the new one, and sent once back online. Settings were kept.