Skip to content

[FSSDK-12682] Fix Jackson serializer crash caused by R8 obfuscation#539

Merged
muzahidul-opti merged 1 commit into
masterfrom
muzahid/FSSDK-12682-fix-jackson-r8-serializer-crash
Jul 23, 2026
Merged

[FSSDK-12682] Fix Jackson serializer crash caused by R8 obfuscation#539
muzahidul-opti merged 1 commit into
masterfrom
muzahid/FSSDK-12682-fix-jackson-r8-serializer-crash

Conversation

@muzahidul-opti

Copy link
Copy Markdown
Contributor

Summary

  • Add consumer ProGuard rules to keep Jackson PropertyNamingStrategies and PropertyNamingStrategy static field names from being obfuscated by R8

The core-api's JacksonSerializer.getSnakeCaseStrategy() uses reflection (Class.getField("SNAKE_CASE")) to look up Jackson naming strategy fields. When an app includes Jackson on its classpath and R8 obfuscates those field names, the reflection lookup fails with NoSuchFieldException, which crashes the DefaultJsonSerializer.LazyHolder static initializer. All subsequent calls to DefaultJsonSerializer.getInstance() then throw NoClassDefFoundError, preventing any event dispatch (impressions and conversions).

Since proguard-rules.txt is already configured as consumerProguardFiles, these rules are automatically merged into any app that depends on the SDK — no manual ProGuard configuration required by customers.

Both PropertyNamingStrategies (Jackson 2.12+) and PropertyNamingStrategy (Jackson 2.11 and earlier) are covered, matching the two-tier reflection fallback in JacksonSerializer.

Test plan

  • Build an app with Jackson on the classpath and R8 minification enabled
  • Verify DefaultJsonSerializer initializes without NoClassDefFoundError
  • Verify event dispatch (impressions and conversions) works through the default SDK path
  • Verify no regression when Jackson is NOT on the classpath (Gson fallback still works)

Issues

  • FSSDK-12682
  • Related: BUG-8620

…uscates naming strategy fields

Add consumer ProGuard rules to preserve Jackson PropertyNamingStrategies
and PropertyNamingStrategy static field names. The core-api's
JacksonSerializer uses reflection (getField("SNAKE_CASE")) to look up
these fields, and R8 obfuscation renames them, crashing the
DefaultJsonSerializer LazyHolder initializer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@muzahidul-opti
muzahidul-opti requested a review from jaeopt July 22, 2026 11:21
@muzahidul-opti

Copy link
Copy Markdown
Contributor Author

@copilot review the pr

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown

@copilot review the pr

The change looks correct. Here's the review:

What the change does:
Adds two -keepclassmembers rules to proguard-rules.txt (which is already configured as consumerProguardFiles) to prevent R8 from obfuscating public static fields on PropertyNamingStrategies (Jackson 2.12+) and PropertyNamingStrategy (Jackson 2.11 and earlier). Without these rules, R8 renames the SNAKE_CASE field, causing the Java SDK core-api's reflection-based lookup (Class.getField("SNAKE_CASE")) to throw NoSuchFieldException, which crashes the DefaultJsonSerializer.LazyHolder static initializer and makes all subsequent calls throw NoClassDefFoundError.

Correctness:

  • -keepclassmembers is the right directive — it preserves both the field names (no obfuscation) and the fields themselves (no removal). -keep would be overly broad here.
  • Covering both PropertyNamingStrategies and PropertyNamingStrategy matches the two-tier fallback in JacksonSerializer.
  • public static * is slightly broad but appropriate — it covers all existing and any future public static naming strategy constants without needing per-field maintenance.
  • When Jackson is absent from the classpath, ProGuard/R8 silently ignores rules for non-existent classes, so there's no impact on Gson-only consumers.
  • Since this is in consumerProguardFiles, the rules are automatically merged into any app depending on the SDK — no manual configuration required.

CI: Both Android CI and Jira ticket reference check pass ✅

@muzahidul-opti
muzahidul-opti merged commit 3257b1d into master Jul 23, 2026
11 of 12 checks passed
@muzahidul-opti
muzahidul-opti deleted the muzahid/FSSDK-12682-fix-jackson-r8-serializer-crash branch July 23, 2026 12:09
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.

3 participants