Dagger: Iinject Generic types in Kotlin with Dagger 2

Created on 25 May 2017  路  2Comments  路  Source: google/dagger

!With NON-GENERIC types this code correctly work!

In module:

@Provides
@Named("test")
fun provideTest(): Factory<Cat> {
    return createdFactory
}

In activity:

@Inject
@Named("test")
lateinit var mFactory: Factory<Cat>

In the end i get an error:
Error:(1, 1) Some error(s) occurred while processing annotations. Please see the error messages above.

Most helpful comment

Run ./gradlew :app:kaptDebugKotlin in console and check errors with the debug mode. I found the problems I had there since the logger was not printing them out properly.

All 2 comments

See https://github.com/google/dagger/issues/668#issuecomment-289713497?

(btw, could you please update your comment to fix the formatting? generics are interpreted as HTML markup and sanitized)

Run ./gradlew :app:kaptDebugKotlin in console and check errors with the debug mode. I found the problems I had there since the logger was not printing them out properly.

Was this page helpful?
0 / 5 - 0 ratings