Colton Idle
05/18/2021, 3:21 AMimplementation(project(":featureX"))
then to featureX build.gradle.kts I added
kotlin("kapt")
id("dagger.hilt.android.plugin")
and
implementation("com.google.dagger:hilt-android:2.35.1")
kapt("com.google.dagger:hilt-compiler:2.35.1")
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
class Blah @Inject constructor() {
fun getName(): String {
return "x"
}
}
run. Compiles. As expected.
Then I go to ChatActivity (my only activity in featureX)
@AndroidEntryPoint
class ChatActivity : AppCompatActivity() {
@Inject lateinit var blah: Blah
compiles, but crashes at Runtime.
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. 😭