With: implementation "androidx.work:work-runtime:2.3.4"
I'm trying to implement custom initialization to enable more verbose logging according to these instructions.
The first snippet has one line bad: return Configuration.Builder() needs to be return new Configuration.Builder().
I extended Application as shown like this:
class MyApplication extends Application implements Configuration.Provider {
@Override
public Configuration getWorkManagerConfiguration() {
return new Configuration.Builder()
.setMinimumLoggingLevel(android.util.Log.INFO)
.build();
}
}
I initiate the worker like this:
WorkManager.getInstance(getApplicationContext());
And yet even after all of that I get the application to crash with this complaint:
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.
Even though the instructions states:
You do not need to call WorkManager.initialize() yourself
Please refer to this link: https://developer.android.com/topic/libraries/architecture/workmanager/advanced/custom-configuration#custom
OR
Initialize your custom WorkManager like this:
// provide custom configuration
val myConfig = Configuration.Builder()
.setMinimumLoggingLevel(android.util.Log.INFO)
.build()
// initialize WorkManager
WorkManager.initialize(this, myConfig)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With