I'm trying to figure out an issue I have with dagg...
# announcements
c
I'm trying to figure out an issue I have with dagger + kotlin. I have a class
Copy code
@Module
class NetworkModule constructor(@Inject public var url: String)
but when I look at the decompiled code in java I see:
Copy code
public final class NetworkModule {
   @Inject
   @NotNull
   private String url;
This is the error I'm trying to figure out "error: Dagger does not support injection into private fields private java.lang.String url;" Not necessarily a dagger issue, but somehow creating a private field in java even though I specify it to be public in kotlin?
j
tried
@Inject constructor(....)
instead? (ie, mark the constructor itself as the injection point instead of the argument)
👍 1
c
oh no. I bet you that's exactly what it is. 🤦‍♂️ Let me give it a whirl.
d
Your property needs to be annotated with @JvmField. Currently it is compiled to a private field with public getter and setter. However I see this is a dagger module which you're not supposed to inject things into. Modules are meant to provide dependencies which you inject elsewhere
☝️ 1