Mobile

One-off WorkManager job removed after app update on Android 11 — scheduled task disappears from scheduler

Environment

Environment

Android app using WorkManager 2.7.0, targetSdk 30, minSdk 21. Devices tested: Pixel 3 (Android 11) and Samsung A (Android 11). Jobs scheduled with WorkManager.enqueueUniqueWork(..., ExistingWorkPolicy.KEEP, oneOffWorkRequest). App updated via Play Store; no Clear Data performed.

Symptoms

Symptoms

A one-off background task scheduled with WorkManager disappears after the app is updated through Play Store. The work no longer appears in WorkManager.getWorkInfosLiveData(...) and doesn't run. Rebooting the device does not restore the job. Scheduling the work again after update succeeds.

Observations

Observations

WorkManager database initially contained the work entry; after update the WorkManager DB (workdb) lacks that entry. Logs during update show application's process restarted and WorkManager reinitialization occurs. No migrations reported in logs. The issue appears only on Android 11 devices and only when WorkManager version was upgraded between app versions; identical app update without WorkManager version bump did not lose scheduled works in internal tests.

Already attempted

Already attempted

Tried reinitializing WorkManager in Application.onCreate(), verified WorkManager.initialize not called multiple times. Tried using enqueueUniqueWork with KEEP and REPLACE variants; behavior same. Upgrading WorkManager to latest stable (2.8.x) in a test branch preserved scheduled works across update in one trial but not consistently across devices.

Question

Question

What causes WorkManager to drop scheduled one-off work entries during app update on Android 11 and how can I make scheduled tasks survive app updates reliably?

COMMUNITY RESPONSES

Verified community troubleshooting

0 replies

No answers yet..

Showing 0 of 0 community responses
AI DIAGNOSTICS

Incident analysis

Updated 4w ago• Trouble ID

Most likely causes

WorkManager version or Room schema change without providing compatible DB migration caused the existing workdb to be replaced/ignored during update 80%
Application code reinitializes WorkManager with a different database name/path on startup, causing a fresh DB on update 45%
Bug in WorkManager or Room on Android 11 that mishandles migrations in certain edge cases 25%

Summary

WorkManager persists scheduled works in an on-disk Room DB; app updates normally keep app data, so works should survive. Losing entries after update commonly happens when WorkManager's schema or initialization changes between library versions causing a DB migration that deletes or ignores existing rows, or when the app update causes WorkManager to reinitialize with a different database name/path. Another root is that the update replaced the WorkManager library without a compatible Room migration, leading WorkManager to recreate the DB empty. Less likely causes include Play Store behavior clearing app data (rare) or manual DB deletion in app startup code.

Suggested Fixes

Diagnostic step 1
Check the WorkManager library version between app releases; if changed, ensure Room migrations are accounted for. Inspect app logs for WorkManager DB migration messages during onCreate or at update time.
Diagnostic step 2
Verify that WorkManager is initialized with the same configuration and database name across app versions (WorkManager.initialize(context, Configuration.Builder().build())).
Diagnostic step 3
Test upgrade path on a device via adb install -r with logging enabled to reproduce and capture WorkManager/Room migration logs.