question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WorkManager error in applications that already utilize WorkManager

See original GitHub issue

OS: Android emulator 7.0, x86_64

I have an application that schedules jobs to WorkManager in its Application.onCreate(). When it crashes, ACRA doesn’t show any dialogs, instead crashes too, with following error:

2019-05-11 11:54:33.399 13071-13071/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.kanedias.dybr.fair.debug:acra, PID: 13071
    java.lang.RuntimeException: Unable to create application com.kanedias.dybr.fair.MainApplication: java.lang.IllegalStateException: WorkManager is not initialized properly.  The most likely cause is that you disabled WorkManagerInitializer in your manifest but forgot to call WorkManager#initialize in your Application#onCreate or a ContentProvider.
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5364)
        at android.app.ActivityThread.-wrap2(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6077)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
     Caused by: java.lang.IllegalStateException: WorkManager is not initialized properly.  The most likely cause is that you disabled WorkManagerInitializer in your manifest but forgot to call WorkManager#initialize in your Application#onCreate or a ContentProvider.
        at androidx.work.WorkManager.getInstance(WorkManager.java:141)
        at com.adonai.MainApplication.rescheduleJobs(MainApplication.kt:71)
        at com.adonai.MainApplication.onCreate(MainApplication.kt:56)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361)
        at android.app.ActivityThread.-wrap2(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6077) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
F43nd1rcommented, Jan 28, 2021

@mueller-ma see fix above. ACRA is not using WorkManager.

0reactions
mueller-macommented, Jan 28, 2021

I have the same crash with ACRA 5.7.0 mail and notification modules.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IllegalStateException: WorkManager is already initialized
If it's not yet initialized, it retrieves the configuration using the getWorkManagerConfiguration() method and then it initializes WorkManager.
Read more >
Persistent Work with WorkManager - Android Developers
Work is persistent when it remains scheduled through app restarts and system reboots. WorkManager is the recommended solution for persistent work.
Read more >
workmanager | Flutter Package - Pub.dev
Flutter Workmanager. This plugin allows you to schedule background work on Android and iOS.
Read more >
WorkManager for Background Work in Libraries
The real problem shows up when you want to use the WorkManager singleton from a library: viz. there can only be one WorkerFactory...
Read more >
Upgrade Android WorkManager 2.5.0 to 2.6.0 | by Peter Nagy
You can find the answer -> "WorkManager now uses androidx.startup to initialize WorkManager. If you used tools:node="remove" the ContentProvider being used ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found