IllegalStateException: WorkManager 已初始化
2022-09-02 01:05:58
具有以下依赖项:
dependencies {
implementation "androidx.work:work-runtime:2.0.1"
androidTestImplementation "androidx.work:work-testing:2.0.1"
}
第二次运行此代码时:
Configuration config = new Configuration.Builder().build();
WorkManager.initialize(getApplicationContext(), config);
this.workManager = WorkManager.getInstance();
我收到此错误消息:
java.lang.IllegalStateException: WorkManager is already initialized.
Did you try to initialize it manually without disabling WorkManagerInitializer?
See WorkManager#initialize(Context, Configuration) or the class level Javadoc for more information.
它还会在本机端抛出分段错误:
A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR),
fault addr 0x878 in tid 10892 (ova.workmanager),
pid 10892 (ova.workmanager)
这将是 的文档。WorkManager#initialize(Context, Configuration)
目的是防止在手动初始化期间崩溃(以便更改日志级别)。如何禁用 ?如果可能的话,我不想使用关键字。WorkManagerInitializer
static