Skip to content

Fix release-only UI freeze: keep DataStore proto classes for R8 - #98

Merged
shreyashp47 merged 3 commits into
mainfrom
fix/r8-wallpaper-freeze
Aug 6, 2026
Merged

shreyashp47 merged 3 commits into
mainfrom
fix/r8-wallpaper-freeze

Conversation

@shreyashp47

Copy link
Copy Markdown
Owner

Summary

Fixes the release-build freeze/ANR (and startup crash) caused by R8 stripping fields that AndroidX DataStore's vendored protobuf accesses reflectively.

  • Reverts the temporary isMinifyEnabled = false / isShrinkResources = false workaround in app/build.gradle.kts — minification stays on.
  • Adds keep rule in app/proguard-rules.pro:
    -keep class androidx.datastore.preferences.PreferencesProto$** { *; }
    

Root cause

androidx.datastore.preferences.protobuf.MessageSchema finds the generated proto class's private backing field preferences_ by name at runtime. R8's shrinker deleted/renamed that field, so the first DataStore Preferences read threw:

java.lang.RuntimeException: Field preferences_ for <obf> not found.
    at androidx.datastore.preferences.protobuf.MessageSchema...

Debug builds were never minified → always worked; the release build froze/crashed.

Verification (on physical device, release APKs)

Config Result
minify+shrink, -dontobfuscate works
minify+shrink, obfuscate on, -dontoptimize crashes with field-not-found
full minify + keep rule (this PR) works

Verified: app boots, navigation responsive, Auto Wallpaper Updates toggle persists and regenerates wallpaper, no crash.

Issue

Closes #97 (full analysis + stack trace commented there).

@shreyashp47
shreyashp47 merged commit 1cca884 into main Aug 6, 2026
2 checks passed
@shreyashp47
shreyashp47 deleted the fix/r8-wallpaper-freeze branch August 6, 2026 07:01
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.

Release build (R8 minified) freezes — auto wallpaper toggle and all inputs unresponsive

1 participant