Exception when not initialized in Application.onCreate
See original GitHub issueI have a use case in which I can’t initialize JobManager
in Application.onCreate
(I’m using android-job in a library and I don’t have access to the application’s Application
class).
Now, if I schedule a job which is run after the application closes, the job will be run without initializing JobManager
and I will get the exception:
IllegalStateException: You need to call create() at least once to create the singleton
This can easily be solved if JobManager
is created before being used in PlatformJobService.onStartJob
using the service context if the singleton doesn’t already exist.
Could you add this change to the project? I could do it myself if you approve.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:7
Top Results From Across the Web
WorkManager not initialized exception even though ...
lang. IllegalStateException: WorkManager is not initialized properly. The most likely cause is that you disabled WorkManagerInitializer in your ...
Read more >Crash on device that FBE is enabled [112665532]
2nd exception: java.lang.IllegalStateException: WorkManager needs to be initialized via a ContentProvider#onCreate() or an Application#onCreate(). I'm ...
Read more >Custom Work Manager initialization | by Michael Spitsin
Aforementioned exception happens because of 2 reasons that present in the project simultaneously: ... As we have multi process application, each ...
Read more >Custom WorkManager Configuration and Initialization
Make sure the initialization of the WorkManager singleton runs either in Application.onCreate() ...
Read more >Modularization of Android Applications with lazy initialization
One more important thing. Modules are not initialized here, i.e. inner components are not created immediately inside Application.onCreate().
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in version
1.0.10
. Thanks for your feedback!If for example I call
JobCreator
inActivity.onCreate
, theJobManager
will call myJobCreator
form then on and jobs are scheduled and run. The problem is when application is not running, this exception (IllegalStateException
) is raised. I may initializeJobCreator
in a service so as it exists even when app is closed but if user force-close the app, this exception will happen again. As I cannot prevent occurrence of this exception in this scenario, I need this exception to not happen. At least even f my jobs are not running, the app still can have its normal behaviour. @vRallev