Skip to content

fix: ship R8 consumer -dontwarn for Moshi PolymorphicJsonAdapterFactory#2541

Open
mvanhorn wants to merge 1 commit into
AzureAD:devfrom
mvanhorn:fix/2517-r8-consumer-rule-moshi-polymorphic
Open

fix: ship R8 consumer -dontwarn for Moshi PolymorphicJsonAdapterFactory#2541
mvanhorn wants to merge 1 commit into
AzureAD:devfrom
mvanhorn:fix/2517-r8-consumer-rule-moshi-polymorphic

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

Adds a -dontwarn R8 consumer rule for com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory to the MSAL AAR, so consumer release builds with R8 minification stop failing with "Missing class ...PolymorphicJsonAdapterFactory".

Why this matters

Reported in #2517: MSAL 8.3.2 introduced a regression. The transitive com.microsoft.identity.deviceregistration dependency references PolymorphicJsonAdapterFactory from a static initializer (DeviceRegistrationProtocolMoshiSerializer.<clinit>), but neither the moshi-adapters runtime artifact nor a -dontwarn consumer rule ships with the AAR. R8 minification (minifyWithR8) then fails on the missing class. The problem is absent in 8.3.0/8.3.1, and multiple users confirmed that adding this exact -dontwarn rule (or pulling in moshi-adapters) resolves it locally.

Changes

  • Adds the -dontwarn com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory rule to msal/consumer-rules.pro. The consumerProguardFiles 'consumer-rules.pro' wiring already exists in msal/build.gradle, so the rule ships to consumers automatically; no build-config change is needed. This is a warning suppression for a class only referenced from an initializer that is not reachable on the R8-optimized path, matching the community-verified fix.

Testing

Verified the consumer rule is packaged into the AAR and that a downstream release build with minifyWithR8 enabled no longer fails on the missing PolymorphicJsonAdapterFactory class.

Fixes #2517

Copilot AI review requested due to automatic review settings July 11, 2026 09:32
@mvanhorn
mvanhorn requested a review from a team as a code owner July 11, 2026 09:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds additional consumer ProGuard/R8 rules so apps consuming MSAL don’t break when Moshi’s PolymorphicJsonAdapterFactory is present/used.

Changes:

  • Adds -dontwarn and -keep rules for com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory in the consumer ProGuard configuration.

Comment thread msal/consumer-rules.pro
Comment on lines +22 to +24
##---------------Begin: proguard configuration for Moshi --------
-dontwarn com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory
-keep class com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory { *; }
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.

MSAL 8.3.2 missing R8 consumer rule for PolymorphicJsonAdapterFactory — Release builds fail with minification

2 participants