Skip to content

Auto Dagger

Auto Dagger allows you to automate some Dagger setup using Hilt.

For example you can use the @AutoInitialize annotation to automatically initialize objects during app launch and you can use the @AutoBind annotation to automatically bind objects.

Automatic initialization is done using AndroidX Startup.

There's also integrations with popular third party libraries such as AndroidX and Retrofit.

You can find the project on GitHub in the ansman/auto-dagger repo.

If you're looking javadoc/dokka you can find it here here.

To get set up see getting started.

Examples

@AutoBind

interface Repository

@AutoBind
@Singleton
class RealRepository @Inject constructor() : Repository

For more detailed documentation see the @AutoBind usage.

@AutoInitialize

@AutoInitialize
@Singleton
class SomeRepository @Inject constructor() {
    init {
        // This will be executed at application startup, even if nobody injects it.
    }
}

For more detailed documentation see the @AutoInitialize usage.