During tests app crashes when trying to initialize WorkManager / WorkManager initializer is not invoked from androidx.startup.InitializationProvider #1026
the app started to crash during appium tests with espresso driver.
Exception:
java.lang.IllegalStateException: WorkManager is not initialized properly. You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider.
Merged manifest file of the app under test has it declared to be initialized via androidx.startup.InitializationProvider
My custom provider was initialized and worked fine. Also I copied code from androidx.startup.InitializationProvider to my second custom provider. It could initialize WorkManger on app launch before WorkManager.getInstance(context); was invoked.
Appium: 2.10.3 Espresso driver: 3.3.0
When I added dependency to app under test
implementation 'androidx.work:work-runtime:2.9.0'
and later in code invoked
WorkManager.getInstance(context);
the app started to crash during appium tests with espresso driver.
Exception:
java.lang.IllegalStateException: WorkManager is not initialized properly. You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider.
Merged manifest file of the app under test has it declared to be initialized via androidx.startup.InitializationProvider
My custom provider was initialized and worked fine. Also I copied code from androidx.startup.InitializationProvider to my second custom provider. It could initialize WorkManger on app launch before
WorkManager.getInstance(context);
was invoked.Here is repos to reproduce the crash:
A bit modified android espresso sample app: https://github.com/Roman-Markov/appium-espresso-reproducible-crash Simple appium test code: https://github.com/Roman-Markov/simple-appium-test-to-reproduce-crash