Skip to content

t1k:unity:base:play-dex-r8-obfuscation-ratio

FieldValue
Modulebase
Version5.116.6
Effortlow
Tools—

Keywords: padding classes, play r8 options, proguard-user.txt, repackage classes, resource shrinking

/t1k:unity:base:play-dex-r8-obfuscation-ratio
<aab> [old.aab] (editor stamp) | padding: gen_obf_pad.py; measurement is core t1k-android-aab-obfuscation

Unity Android obfuscation remediation (Play “Obfuscation” threshold)

Section titled “Unity Android obfuscation remediation (Play “Obfuscation” threshold)”

Unity-only: what to change in a Unity Android build when the Play obfuscation number fails. Launcher template, Play R8 options, padding classes and the SDK and Crashlytics gotchas live here.

Measurement is not here. The AAB measurement (proguard.map ratio, per-package compare, r8.json cross-check, Maven library list, Waydroid smoke test) is engine-neutral and ships in the core skill t1k-android-aab-obfuscation. Do not re-implement it in this skill.

No Editor, no mutex. Pure zip reads for the measurement. Never launch Unity to measure a bundle.

Terminal window
S="$(ls -d .claude/skills/t1k-android-aab-obfuscation "$HOME/.claude/skills/t1k-android-aab-obfuscation" 2>/dev/null | head -1)/scripts"

If test -d "$S" fails, the core skill is not installed: run t1k modules update (the dependency on t1k-reverse-engineering pulls the host module), then retry. Invoke every core script as python3 -I "$S/<script>". Exit codes are the core skill’s: 0 PASS, 1 FAIL, 2 usage, no map, or unreadable bundle.

Call AskUserQuestion (multi-select) with these two options and nothing else. Do not offer any edit to ad-network or SDK consumer rules: changing them does not raise the obfuscation ratio (owner decision 2026-11-13).

OptionStatusWhat it does
Play R8 options (Resource Shrinking, Resource Shrinking Optimized, Repackage Classes)DEFAULT: pre-selected, always appliedEnable steps: references/play-r8-options.md. Smoke-test before any tester upload (Gotchas).
Padding classesOPTION, off by defaultLifts Play’s number and protects nothing. Sizing and costs: references/padding-classes.md.

Apply the chosen options, then re-measure the new bundle with the core skill: python3 -I "$S/obfuscation_check.py" <new.aab>. Padding is generated only after the user picks it (scripts/gen_obf_pad.py deletes and rewrites its --out directory).

Terminal window
U=.claude/skills/t1k-unity-base-play-dex-r8-obfuscation-ratio/scripts
python -I "$U/unity_editor_version.py" app.aab [old.aab] # Unity editor version stamp (exit 0 / 2)
python -I "$U/gen_obf_pad.py" --out <Unity>/Assets/Plugins/Android/ObfPad --package com.<app>.obfpad # padding (option, user-chosen)
  • With the three items ON the app crashes at start unless the Crashlytics build id is kept. com.crashlytics.android.build_id is removed from base/resources.pb (present with the options OFF, absent with them ON): start fails with “The Crashlytics build ID is missing”. A res/raw/keep.xml with only the dotted tools:keep name did NOT prevent it (MimicThatSound #121). A keep.xml listing the dotted AND underscore names (@string/com_crashlytics_android_build_id) plus wildcards (com.crashlytics.*, com_crashlytics_*) DID (MimicThatSound #122: id back in resources.pb, app starts on Waydroid). Which spelling is the effective one was not isolated (several changed in one build). The unity-version resource is com.google.firebase.crashlytics.unity_version, not com.crashlytics.android.unity_version. Do not upload a build with the options ON to testers without a start-up smoke test ("$S/waydroid_test.sh", core). Detail and the file: references/padding-classes.md § Gotcha.
  • A Jenkins job without a branch parameter builds ONLY its configured branch spec. MimicThatSound’s Release job built */chore/applovin-sdk-8-6-6 (version 8-6-6, no padding, 18.61%) when release-1.0.2 was wanted; a push to the branch it watches also auto-triggers a build, and kit-sync commits (.claude/ only) trigger one each. Before trusting a number, read the log’s Selected branch: and Version: ... Commit: lines.
  • Measuring through Jenkins: a Release-job build can be a stale commit (a push event queued it): supersede it with a forced trigger and check the SHA. Packages can resolve to old versions: wipe the workspace (PARAM_WIPE_OUT_WORKSPACE=true, which ends in failure by design) before trusting the numbers. Root cause not proven: references/known-causes.md § Measuring through Jenkins.
  • Global R8 options do not belong in proguard-user.txt. Unity exports it as the unityLibrary consumerProguardFile; -repackageclasses, -allowaccessmodification, -dontobfuscate, -dontoptimize, -dontshrink, -overloadaggressively… fail the build in :unityLibrary:exportReleaseConsumerProguardFiles (Gradle error “Global keep option … should not be used in a consumer rules file”). They need a non-consumer rules file (custom launcherTemplate.gradle). isAccessModificationEnabled is already true in Unity 6 / R8 9.x, check r8.json options first (core r8 subcommand).
  • Narrowing project keep rules moves the metric little. Measured on SprunkiSoundCollection: removing broad -keep for ironsource/gms/play-core/facebook/kotlin.collections took Play obf/opt/shrink from 19.47/19.31/25.09 to 21.01/20.85/27.25. What stays kept is SDK-shipped consumer rules (yads, inmobi, ironsource, appmetrica, chartboost), which a project rule cannot undo: only dropping the adapter moves it.
  • AppLovin Quality Service (SafeDK) pins half the DEX. AppLovinSettings.asset qualityServiceEnabled: 1 makes the com.applovin.quality Gradle plugin write Gradle/.safedk/proguard-safedk.pro: 77 broad -keep rules (androidx.**, okhttp3, com.applovin.**, ironsource, vungle, unity3d.ads, gms.ads…). Measured: turning it off cut the DEX 68.4k to 57.9k classes and moved Play obf/opt/shrink 21.01/20.85/27.25 to 22.64/22.53/29.87. It also turns off AppLovin Ad Review, so it is a product call, not a free fix.
  • Reading the merged R8 rules (which SDK keeps what). Not -printconfiguration in proguard-user.txt (AGP rejects it there), not a path under the workspace (not archived), not stdout (not in the log). Use a custom launcherTemplate.gradle (useCustomLauncherGradleManifest: 1) with a tasks.configureEach hook that prints launcher/build/outputs/mapping/release/configuration.txt after minifyReleaseWithR8 and then throws: Unity prints Gradle output only when Gradle fails. Each rule carries its origin file.

Deeper cause catalogue and worked numbers: references/known-causes.md.

The core scripts are deterministic reads of a finished bundle: t1k-fact-fetcher (haiku) runs them and quotes their output verbatim. The diagnosis (which packages stayed kept, what a drop means) and any change to keep rules stay with the reasoning-tier caller (t1k-unity-base-developer). scripts/gen_obf_pad.py is not a measurement: it deletes and rewrites its --out directory, so it stays with the caller too, and only after the user has chosen padding.

Unity remediation for a failing Play obfuscation threshold: launcher template, Play R8 options, padding, SDK rules, and the Unity build gotchas above. Not: measurement or diagnosis of an AAB (core t1k-android-aab-obfuscation), the Unity build gate (t1k-unity-base-build-gate), Editor compile/run verbs (t1k-unity-editor-cli), or the Play upload itself (CI/Jenkins).

  • t1k-android-aab-obfuscation (core, t1k-reverse-engineering module) — the measurement and the diagnosis table
  • t1k-unity-base-build-gate — failing a build in the Editor/CI instead of measuring a finished bundle
  • t1k-jenkins-build, t1k-jenkins-unity — where the AAB is produced
  • references/known-causes.md — the 2026-10 editor-version drop on this project; Jenkins measuring gotchas
  • references/padding-classes.md — padding classes and Play’s three R8 items, 2026-11 measurements (MimicThatSound, TheOneFeatureProject)
  • references/play-r8-options.md — enabling the three Play R8 items on Unity 6000.3.25f1 / AGP 9.0.0 (verified 2026-11-13)
  • references/consumer-rule-override.md — reference only; not suggested for raising the ratio (owner decision 2026-11-13)