FunnyDevs/hilt-conductor

Injection not working

Closed this issue · 6 comments

I followed your instructions but nothing is injected. I have a simple Module:

@Module
@InstallIn(ControllerComponent::class)
object HiltModule {
    @Provides
    fun provideLogger(): Logger {
        return LoggerImpl(true)
    }
}

The controller is simple too

@ConductorEntryPoint
class MatchesController : BaseController() {
    @Inject
    lateinit var logger: Logger

When the app runs it crashes with
kotlin.UninitializedPropertyAccessException: lateinit property logger has not been initialized

Am I doing something wrong?

Ok so your readme misses the part where you add your plugin to the Gradle script...
id("com.funnydevs.hilt-conductor.plugin")

Look at the step 2

Step 2. Apply plugin in application module of build.gradle.

plugins {
    ...
    id 'dagger.hilt.android.plugin'
}

Look at the step 2

Step 2. Apply plugin in application module of build.gradle.

plugins {
    ...
    id 'dagger.hilt.android.plugin'
}

Yes, that's the Hilt plugin but you also need your funnydev plugin.

plugins {
    id("com.funnydevs.hilt-conductor.plugin")
    id("dagger.hilt.android.plugin")
}

Ah, you are right, i have confused dagger plugin with my own :D. I will update it immediately

Ah, you are right, i have confused dagger plugin with my own :D. I will update it immediately

Thank you for writing the plugin btw. I really appreciate it. I still like Controllers better than Fragments ;-)

me too, i hate Fragments!
As soon as i have time, i'll implement the @nAmed qualifier handling