2.38 - lateinit property workerFactory has not been initialized
See original GitHub issue
@HiltAndroidApp
class MyApplication : Application(), Configuration.Provider {
@Inject
internal lateinit var workerFactory: HiltWorkerFactory
override fun getWorkManagerConfiguration() =
Configuration.Builder()
.setExecutor(Dispatchers.Default.asExecutor())
.setWorkerFactory(workerFactory)
.setTaskExecutor(Dispatchers.Default.asExecutor())
.setMaxSchedulerLimit(MAX_SCHEDULER_LIMIT)
.build()
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cisystems.ssmp.arm_vmb2, PID: 13731
java.lang.RuntimeException: Unable to create service com.cisystems.ssmp.arm_vmb2.services.HeartbeatService: kotlin.UninitializedPropertyAccessException: lateinit property workerFactory has not been initialized
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3544)
at android.app.ActivityThread.access$1300(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property workerFactory has not been initialized
at com.cisystems.ssmp.arm_vmb2.MyApplication.getWorkerFactory$app_minApi23Debug(MyApplication.kt:37)
at com.cisystems.ssmp.arm_vmb2.MyApplication.getWorkManagerConfiguration(MyApplication.kt:42)
at androidx.work.impl.WorkManagerImpl.getInstance(WorkManagerImpl.java:155)
at androidx.work.WorkManager.getInstance(WorkManager.java:184)
at com.cisystems.ssmp.arm_vmb2.workers.DirectoryUpdateWorker$Companion.stop$app_minApi23Debug(DirectoryUpdateWorker.kt:337)
at com.cisystems.ssmp.arm_vmb2.services.HeartbeatService$Companion.stopExecutes(HeartbeatService.kt:57)
at com.cisystems.ssmp.arm_vmb2.services.HeartbeatService$Companion.access$stopExecutes(HeartbeatService.kt:36)
at com.cisystems.ssmp.arm_vmb2.services.HeartbeatService.onCreate(HeartbeatService.kt:66)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3532)
at android.app.ActivityThread.access$1300(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:6 (1 by maintainers)
Top Results From Across the Web
lateinit property WorkerFactory has not been initialized - Stack ...
The way you initialized your workmanager and workmanagerfactory is only working till workmanager version 2.5.
Read more >Could not instantiate Worker when using Hilt for dependency ...
I believe that all configuration is correct in my project. I attached a sample project to this post. In case anyone is interested,...
Read more >lateinit property ApplicationContext has not been initialized ...
Inject the context to the respective file where it needs to be used via constructor and use that instance. You can also use...
Read more >WorkerFactory - Android Developers
The returned worker must be a newly-created instance and must not have been previously returned or invoked by WorkManager.
Read more >You can check whether the lateinit property has been ... - Reddit
At times this can be useful like if an object will definitely be initialised in all places except 1 where it may not...
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
@BugsBunnyBR if this is an issue with ContentProviders calling before
onCreate()
you should be able to fix that issue by using an entry point instead of relying on field injection. For example:The entry point will take initiative to create the component if it’s not already created.
The original report sounds like #2784 is the cause. Closing this assuming that is the case.