From 6e14d5964bd85078bce2ab526571f3fb6dc49761 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Thu, 18 Jun 2026 16:15:08 +0200 Subject: [PATCH] fix(release): keep Room DB impls so R8 doesn't crash startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The minified release build crashed on every launch before any UI: Unable to get provider androidx.startup.InitializationProvider: Failed to create an instance of androidx.work.impl.WorkDatabase The home-screen widgets use Glance, which pulls in WorkManager and its transitive Room database (room-runtime 2.2.5). Room 2.2.5's bundled keep rule is `-keep class * extends androidx.room.RoomDatabase` — it keeps the class but not its constructor. Under R8 full mode (AGP 9) the generated WorkDatabase_Impl was reduced to a non-instantiable class, so Room's reflective newInstance() threw InstantiationException at startup. Add `-keep class * extends androidx.room.RoomDatabase { *; }` so the generated *_Impl classes keep their constructors. Verified against the rebuilt release APK: WorkDatabase_Impl is now PUBLIC FINAL with its present. Co-Authored-By: Claude Opus 4.8 (1M context) --- CHANGELOG.md | 6 ++++++ app/proguard-rules.pro | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98bdf47..dc81524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 anything Calendula can't represent (changed recurring occurrences, guest lists) is reported rather than silently dropped. +### Fixed +- Fixed the app crashing immediately on every launch in the optimized release + build: release code-shrinking (R8) was stripping a database class the + home-screen widget framework needs, so the app died at startup before showing + anything. Added the missing keep rule. + ## [2.6.0] — 2026-06-18 ### Added diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index dccc1da..dce5b77 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -4,3 +4,14 @@ # Compose Compiler may keep its own; defaults are fine -dontwarn org.jetbrains.annotations.** + +# Room database implementations (pulled in transitively via +# androidx.glance:glance-appwidget → androidx.work → androidx.room). +# The widgets rely on Glance, whose WorkManager backend stores state in a Room +# database. Under R8 full mode (AGP 9 default) the generated *_Impl subclasses +# of RoomDatabase lose their usable no-arg constructor / are marked abstract, +# so Room's reflective instantiation throws InstantiationException and the app +# crashes at startup with "Failed to create an instance of ...WorkDatabase". +# Keep the generated Room database implementations fully intact. +-keep class * extends androidx.room.RoomDatabase { *; } +-dontwarn androidx.room.paging.**