Hi, Any ideas on how to make this work?
I need to observe the API URL change from shared preferences in the APIModule but Hilt doesn't like the idea of injecting constructor here...
Modules that need to be instantiated by Hilt must have a visible, empty constructor.
Would field injection work (instead of constructor injection)?
s
Sergio C.
11/01/2022, 11:18 PM
It didn't work either. lateinit var localPrefs is not initialized.
s
streetsofboston
11/01/2022, 11:20 PM
They won't be initialized at the time that
init { .... }
is called; they'll be initialized a bit later.
You may need to create a (lazy) accessor or create a method you'd need to call explicitly to do what happens originally in your