https://kotlinlang.org logo
Title
b

bod

05/21/2017, 1:37 PM
So… I’m not sure what the current status is - are we currently supposed to use
apply plugin: 'kotlin-kapt'
or is it an experimental thing? I mean you can use
kapt
dependencies even if you don’t do it, but it works differently it seems - which is a bit confusing. Any clarification on this would be much appreciated 🙂
i

igoticecream

05/21/2017, 5:39 PM
@bod kapt is the "apt" or "annotationProcessor" for kotlin, it is used to generate code at compile time based on annotations, for things like dagger and butterknife
b

bod

05/21/2017, 5:41 PM
Yes I understand that, but it seems that you can use
kapt
dependencies in gradle project even if you don’t use the
kotlin-kapt
plugin. And if you do use this plugin, you get a different version of
kapt
. Is this correct?
l

lovis

05/22/2017, 7:19 AM
yes,
kotlin-kapt
is kapt3. Works well for us
b

bod

05/22/2017, 8:34 AM
@lovis Ok so if you don't apply the plugin, you get an older
kapt
? Like, v2? Whereas if you use it, you get
kapt3
?
l

lovis

05/22/2017, 8:36 AM
yeah
b

bod

05/22/2017, 8:38 AM
ok thanks. And do you use
generateStubs
? This seems to be optional, or not, depending on which version 😉
l

lovis

05/22/2017, 8:41 AM
no you are not allowed to use that with kapt3
i think its supposed automatically fall back to an older kapt version if you use that, but for me it simply didn’t compile
b

bod

05/22/2017, 8:46 AM
hmm interesting
do you use Dagger by any chance? The reason I'm asking is that I think the generated stubs are incorrect (public fields end up private)
l

lovis

05/22/2017, 9:20 AM
yes I’m using dagger. I don’t have issues like that. Maybe clean build helps? 🙂
compile "com.google.dagger:dagger:$dagger_version"
    kapt "com.google.dagger:dagger-compiler:$dagger_version"
b

bod

05/22/2017, 9:25 AM
I suppose you use
lateinit
for your injected fields? In this case they are correctly public.
l

lovis

05/22/2017, 10:42 AM
yes that’s right.
so what are you doing?
@Inject var myField: Thing? = null
or are you using
notNull
delegate
b

bod

05/22/2017, 11:28 AM
that's right,
@Inject var myField: Thing? = null
- of course it makes more sense with
lateinit
🙂 But this should work anyway so I think it's a bug
l

lovis

05/22/2017, 1:23 PM
I think so too. https://kotlinlang.slack.com/archives/C0B8MA7FA/p1495442168869554 ⬅️ this guy seems to have a similar issue. maybe file a bug (or ask whether it’s known first in #general)
b

bod

05/22/2017, 1:29 PM
ok, will do 🙂 Thanks