Skip to content

Replace HiltWorker with a Hilt entry point - #347

Closed
fornewid wants to merge 1 commit into
developfrom
remove-hilt-worker
Closed

fornewid wants to merge 1 commit into
developfrom
remove-hilt-worker

Conversation

@fornewid

@fornewid fornewid commented Oct 4, 2026

Copy link
Copy Markdown
Member

AndroidX HiltWorker is replaced with a Hilt entry point, which also removes the custom WorkManager setup it needed.

  • SyncOpenDateWorker and AnnounceOpenDateWorker use WorkManager's default (Context, WorkerParameters) constructor and get their use case from WorkerEntryPoint (renamed from InitializerDependencies).
  • WorkManager uses its default initializer and worker factory, so WorkManagerInitializer, InitializerComponent and the module manifest (the androidx.startup provider config) are removed.
  • androidx.hilt:hilt-work, ksp androidx.hilt:hilt-compiler and their catalog entries are removed, along with the redundant id "com.google.devtools.ksp" (moop.android.hilt already applies KSP).

Baselines

  • dependencyGuard drops androidx.hilt:hilt-common and androidx.hilt:hilt-work.
  • The proguardShield fast baseline drops hilt-work's -keepnames @androidx.hilt.work.HiltWorker class * extends androidx.work.ListenableWorker. The default factory instantiates workers by class name, and work-runtime's own rules (-keepnames class * extends androidx.work.ListenableWorker, public <init>(...)) still keep the names and constructors it needs. R8's seeds for the release build list both workers and their (Context, WorkerParameters) constructors.
  • The checked-in baseline profiles still mention the deleted classes. That's harmless until they're regenerated.

Verification

  • On an API 36 emulator, WorkManager initializes with its default configuration and MainViewModel schedules both periodic works. A temporary one-time enqueue (not committed) ran both workers, and both ended with Worker result SUCCESS.
  • :app:minifyReleaseWithR8 keeps both worker classes unobfuscated, with their constructors.
  • ./gradlew :app:assembleDebug dependencyGuard manifestShield proguardShieldFast moduleRules passes, and the manifestShield and module-rules baselines are unchanged.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01Upxj1FvQeDpycupKdPQHUZ

The two workers now use WorkManager's default (Context, WorkerParameters)
constructor and get their use case from WorkerEntryPoint, so WorkManager
can use its default initializer and worker factory. Remove the custom
WorkManagerInitializer, its Dagger component, the startup provider
manifest, androidx.hilt:hilt-work and its compiler, and the redundant
KSP plugin declaration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Upxj1FvQeDpycupKdPQHUZ
@fornewid
fornewid force-pushed the remove-hilt-worker branch from 448031c to fbd2372 Compare October 4, 2026 04:10
@fornewid

fornewid commented Oct 4, 2026

Copy link
Copy Markdown
Member Author

Closing: this change wasn't requested.

@fornewid fornewid closed this Oct 4, 2026
@fornewid
fornewid deleted the remove-hilt-worker branch October 4, 2026 04:25
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