Perhaps a very "getting-started" question, but it is multiplatform.
AS is showing some code in red but still builds and runs the app. I'm guessing that this means I've got something skewiff with dependencies in my build.kts file, but I don't know what.
In commonMain ktor in "import io.ktor.client.features.*" is red, and so are ClientRequestException and response in "e.response" (although Exception in "e: Exception" is fine).
It may be these lines of code haven't run, but that shouldn't be relevant here, surely?
10/08/2021, 9:38 AM
AFAIK IntelliJ keep stuff in memory but delegates the build to Gradle. If it builds your project is right, and that could mean IntelliJ is not properly synchronized with Gradle. You can start with "reload all gradle projects" or "invalidate cache and restart". (Only general advice here, I don't know about this specific case.)
10/08/2021, 1:37 PM
Thanks for that @Grégory Lureau and on closer inspection it seems the problem is more widespread. It also resists any number of restarts, cache clearing, or rebuilds.
It seems that every external import fails only in commonMain. Identical imports in androidMain are fine!😞
10/08/2021, 1:39 PM
Are you importing a KMP library in common? I suppose that if you try to import a Java/Android lib it could fail to recognize the format.
10/08/2021, 2:00 PM
It's things like ktor (mentioned originally), kotlinx.serialization, coroutines... 😟
10/10/2021, 9:43 AM
This can happen for many reasons. But usually there is some explanation when app is built. It's rarely a red error, usually it's a yellow warning. Try to clean and then build and see what the full log tells you
Also for me it was lack of a kotlinx.serialization dependency for one of the targets. It built just fine because it was merged to the codename transitivity but Android Studio required explicit declaration, otherwise stuff was red