Skip to content

Crashlytics: use R8 r8-map-id on AGP 8.12+#8306

Open
jrodiz wants to merge 1 commit into
firebase:mainfrom
jrodiz:feature/jrc--6770.r8-map-id-on-agp9
Open

Crashlytics: use R8 r8-map-id on AGP 8.12+#8306
jrodiz wants to merge 1 commit into
firebase:mainfrom
jrodiz:feature/jrc--6770.r8-map-id-on-agp9

Conversation

@jrodiz

@jrodiz jrodiz commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

#6770

injectCrashlyticsMappingFileIdRelease minted a new random id on every minified release build and wrote it into a generated resource, cascading through mergeResources → R8 → packaging and 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 matching r8-map-id in 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

  • New UploadMappingFileForR8MapIdTask task: reads the map id from the merged mapping file and uploads with it. Falls back to pg_map_id (the only id R8 emits today) but prefers an r8_map_id header defensively if a future R8 ever writes one. Warns and skips when no id is present.
  • InjectMappingFileIdTask serves both paths via two factory methods: registerForR8MapId injects the constant USE_R8_MAP_ID sentinel (all ones, blank when no mapping is uploaded); register keeps the legacy blank/random behavior. Being constant, the AGP 8.12+ resource is byte-identical across rebuilds and keeps the release build cache valid.
  • CrashlyticsPlugin gates on AGP version: >= 8.12 registers the sentinel inject + new upload tasks; < 8.12 keeps 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 :assembleRelease across five AGP versions on JDK 17, each AGP paired with its required Gradle version, and the resulting app/build/outputs/mapping/release/mapping.txt header inspected:

AGP bundled R8 compileSdk pg_map_id length r8_map_id present?
8.1.4 8.1.68 34 7 (prefix) no
8.7.3 8.7.18 34 7 (prefix) no
8.11.2 8.11.26 35 7 (prefix) no
8.12.0 8.12.14 35 64 (full hash) no
8.13.0 8.13.6 35 64 (full hash) no
9.1.0 9.1.31 36 64 (full hash) no
9.2.1 9.2.14 36 64 (full hash) no

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.
@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

@jrodiz jrodiz requested a review from mrober June 15, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant