Crashlytics: use R8 r8-map-id on AGP 8.12+#8306
Conversation
Gate the r8-map-id path at AGP 8.12 (where R8 embeds it). Upload the mapping keyed by the extracted map id (prefer r8_map_id, fall back to pg_map_id) and inject a constant sentinel id resource so the SDK uses the r8-map-id. Fixes firebase#6770.
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
#6770
injectCrashlyticsMappingFileIdReleaseminted a new random id on every minified release build and wrote it into a generated resource, cascading throughmergeResources → R8 → packagingand invalidating the build cache on every release.Since AGP 8.12, R8 stamps a stable, content-derived map id (
pg_map_id) into the mapping file and embeds the matchingr8-map-idin obfuscated stack frames. On AGP 8.12+ we consume that id instead of minting our own — stable when the obfuscated output is unchanged, regenerated only when it changes. No churning id, no cache busting.Changes
UploadMappingFileForR8MapIdTasktask: reads the map id from the merged mapping file and uploads with it. Falls back topg_map_id(the only id R8 emits today) but prefers anr8_map_idheader defensively if a future R8 ever writes one. Warns and skips when no id is present.InjectMappingFileIdTaskserves both paths via two factory methods:registerForR8MapIdinjects the constantUSE_R8_MAP_IDsentinel (all ones, blank when no mapping is uploaded);registerkeeps the legacy blank/random behavior. Being constant, the AGP 8.12+ resource is byte-identical across rebuilds and keeps the release build cache valid.CrashlyticsPlugingates on AGP version:>= 8.12registers the sentinel inject + new upload tasks;< 8.12keeps the original inject + upload behavior unchanged.Verification
To confirm the standalone results reflect real AGP-driven builds, a minimal Android app (one kept entry class + one obfuscated helper,
isMinifyEnabled = true, default optimize rules) was built with:assembleReleaseacross five AGP versions on JDK 17, each AGP paired with its required Gradle version, and the resultingapp/build/outputs/mapping/release/mapping.txtheader inspected:pg_map_idlengthr8_map_idpresent?