我在我的应用程序中使用Work Manager,使用最新的库
implementation 'androidx.work:work-runtime:2.7.1'
在清单文件中
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove">
</provider>
应用程序类
class App : Application(), Configuration.Provider {
override fun getWorkManagerConfiguration() =
Configuration.Builder()
.build()
override fun onCreate() {
super.onCreate()
WorkManager.initialize(this, Configuration.Builder().build())
}
}
我已经在应用程序类中添加了初始化。但是我仍然遇到了这个错误。
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.