https://kotlinlang.org logo
#android
Title
# android
e

Edwin Ramirez Ventura

09/28/2017, 2:05 PM
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

megax

09/28/2017, 2:09 PM
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

Edwin Ramirez Ventura

09/28/2017, 2:14 PM
Its works now, thanks!
👍 1
m

megax

09/28/2017, 2:16 PM
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

Edwin Ramirez Ventura

09/28/2017, 2:29 PM
xD
do you any link of a Dagger2.11 tutorial?
I'm having a lot of trouble implementing it
r

Ricardo

09/28/2017, 3:56 PM
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

Edwin Ramirez Ventura

09/28/2017, 4:07 PM
Thanks for the repository and article
r

Ricardo

09/28/2017, 4:08 PM
👍
e

Edwin Ramirez Ventura

09/28/2017, 4:10 PM
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

Ricardo

09/28/2017, 6:25 PM
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

Edwin Ramirez Ventura

09/28/2017, 6:29 PM
I've done it previously but with Java
r

Ricardo

09/28/2017, 6:35 PM
Yeah, I know that it works in Java. As for Kotlin, I'm not so sure...
😔 1
👍 1
7 Views