https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
a

aishwaryabhishek3

11/24/2023, 10:13 AM
Does Anvil have issues with kotlin 1.9.20 ? I am running into weird stuff and always need to run with --rerun-tasks to make sure it compiles correctly.
s

Stephen Edwards

11/24/2023, 6:13 PM
Is this related to https://github.com/square/anvil/issues/693 ? And not just Kotlin 1.9.20?
a

aishwaryabhishek3

11/26/2023, 10:00 AM
I don’t think so because the errors I was receiving was not related to multibinding, if the bug however is related to the new incremental compilation and not specific to Multibinding then I would think that would be the root cause because --rerun-tasks works fine.
j

Joel Wilcox

11/28/2023, 12:07 AM
Although that GH issue started out focused on multibindings, it is not limited to multibindings and is currently being used to track overall incremental compilation issues, so it's likely the root of the issue you're running into. That said, if you've only noticed the issue with Kotlin 1.9.20 that could be helpful additional info
a

aishwaryabhishek3

11/28/2023, 5:51 AM
We made a big jump from 1.7.21 to 1.9.20 directly and could not really try it out on other kotlin versions . But the error always seems to be happening when we touch a particular gradle module and not with all modules , will post my findings here or update in the GH issue if I find anything useful.
By the way would adding
kotlin.incremental.useClasspathSnapshot=false
make sure that we do not run into this issue ? Because I am seeing issues with @ContributesTo annotation as well and it crashes at runtime .
j

Joel Wilcox

11/28/2023, 7:37 AM
Ahh gotcha, that makes sense why you're suddenly seeing the issue then. It has been around for a while but was encountered pretty rarely until Kotlin 1.8.20 (or whichever version flipped the new incremental compiler flag to be on by default, which exacerbated the underlying issue).
kotlin.incremental.useClasspathSnapshot=false
will not resolve the issue, although it may reduce the situations/frequency in which you encounter it. We're currently working on a (hopefully) more permanent fix but no current estimate on when that will be available
👍 1
a

aishwaryabhishek3

11/28/2023, 7:42 AM
Thanks , I went through the comments and will try the couple of workarounds people have posted , especially the one where we modify the kaptGenerateStubs one . Otherwise might just have to live with --rerun-tasks whenever we face an issue .
Just want to confirm that running with --rerun-tasks will for sure fix any issues between anvil and IC right ?
j

Joel Wilcox

11/28/2023, 6:29 PM
Yes --rerun-tasks should always work, or at least I haven't heard from any folks where it didn't work. You can potentially get by with rerunning individual tasks with --rerun which would be faster than using --rerun-tasks but that's a bit more error prone since you have to identify the right module(s) and something may still be missed.
🙌 1