Hi all, I have ported my Android project to KMP. I...
# multiplatform
s
Hi all, I have ported my Android project to KMP. I got one question about common code. when ever I move any of my code to
commonMain
other modules can not resolve that code correctly. so some functions will turn red and the ide will not help with compilation. the worst part is I can not use
cmd + b
to see the declaration, because it takes me the compiled code. All these unresolved codes are ok when I run/compile the App. Touchlab Kamp starter has the same problem too
Bread
is not resolved but project can be run (check image). is there any fix I can apply to resolve this issue? ‌Bread is missing.jpg
2
s
I noticed this as well, just after updating to 1.4. I don't know what fixed it in the end, but it seems to be better now. Either
File > Invalidate caches, restart
or reimporting the project after removing the .idea folder and gradle cache. I'm interested in understanding the bug though
s
I have done all this but no luck so far. it’s not only on a single project either. I have it on any project that has multiplatform
s
That's annoying. I remember the usual tricks didn't work right away so I though it was a build issue, but then it resolved itself... This applied to all classes in all linked modules. There was also a seperate issue where sqldelight classes were not auto generated and I had to manually call the sqldelight build task for them to resolve. (using version 1.4.2 of sqldelight)
m
I've been super annoyed by this for some time too. I recently filed https://issuetracker.google.com/issues/165921901 but it looks like yours is slightly different
If you file a bug, link it here so we can add
I think using the kotlin multiplatform plugin in all modules improves the situation but I'm not sure if it's enough.
a
I started seeing this before upgrading to IntelliJ 2020.2, after that upgrade everything turned red on me. I had to go back. Upto date, I am using that and Android studio 4.1 Canary 7
r
Can you file a KaMPKit bug? Since it’s just the generated database class that’s failing to resolve, I’m guessing this is due to https://github.com/cashapp/sqldelight/issues/1894 and needs an update to SqlDelight 1.4.2
s
I don't think it's related to Sqldelight or Kamp project setup. I have 2 other projects with KMP and the same issue exist there too (I'll post SS shortly). The issue in short happens when I reference any of the classes that live in the commonMain package from android package directory. And we could not resolve it with sync,build,clean and also tested on 5 different machines with different OS.
sorry for the delay here is another example. so it seams the class names are fine the functions are not. please note the declaration is in
commonMain
and the usage is in
androidMain
First Function Declaration of States
I think this might be the same problem as @mbonnin