I'm trying to implement Dagger2 with Kotlin but I'...
# android
e
I'm trying to implement Dagger2 with Kotlin but I'm getting the following error: A @Module may not contain both non-static @Provides methods and abstract @Binds or @Multibinds declarations
m
put the other methods with @Provide into a companion object inside your class and annotate it with @Module too. And in this companion object annotate every single function with @JvmStatic
πŸ‘ 1
e
Its works now, thanks!
πŸ‘ 1
m
But I would be interested if there is any better solution for this... I don't like to add @JvmStatic to every methods there... πŸ˜„
πŸ‘ 1
e
xD
do you any link of a Dagger2.11 tutorial?
I'm having a lot of trouble implementing it
r
You can check my repo. Kotlin with dagger and other libraries: https://github.com/bboy79/kotlin-template
πŸ‘ 1
Gimme a sec, I'll post a tutorial here as well
e
Thanks for the repository and article
r
πŸ‘
e
does Dagger support method injection?? I've seen your repository to find something like that and I've only seen constructor injection
I have a class that have a constructor and method annotated with inject but only the constructor get called. Code: https://pastebin.com/VAzdRsbR
r
Never tried it. Dagger supports method injection, but as far as I know it's not that common. Not sure if kotlin supports it as well
e
I've done it previously but with Java
r
Yeah, I know that it works in Java. As for Kotlin, I'm not so sure...
πŸ˜” 1
πŸ‘ 1