I'm currently using hilt in a single gradle module...
# dagger
I'm currently using hilt in a single gradle module application. Everything works great. Now I added a new module called featureX. featureX contains a ChatActivity and ChatViewModel. I also want to use dependency injection in this new gradle module. In my app module I added
Copy code
then to featureX build.gradle.kts I added
Copy code
Copy code
If I build the app and navigate to ChatActivity. Everything works fine. As expected, I'm not introducing DI yet. I add a new class to featureX
Copy code
class Blah @Inject constructor() {
    fun getName(): String {
        return "x"
run. Compiles. As expected. Then I go to ChatActivity (my only activity in featureX)
Copy code
class ChatActivity : AppCompatActivity() {
    @Inject lateinit var blah: Blah
compiles, but crashes at Runtime.
Copy code
Caused by: java.lang.ClassCastException: com.rollertoaster.app.DaggerRollerToasterApplication_HiltComponents_SingletonC$ActivityRetainedCImpl$ActivityCImpl cannot be cast to com.rollertoaster.featureX.ChatActivity_GeneratedInjector
Ideas? It's my first time using multi modules and I'm not great at dagger/hilt and so maybe I'm making a noob mistake here. EDIT: Clean and rebuild fixed it. ­čśş
­čĄ¬ 3