Hi multi platform enthusiast, today I ran into an ...
# multiplatform
u
Hi multi platform enthusiast, today I ran into an issue with Android Studio, where gradle sync failed in
compileCommonMainKotlinMetadata
due to an error in one of my actual app source files. (just a typo in the imports). I don’t think I have ever seen that on pure android projects so it was quite surprising to me to see that the actual app sources are relevant for the sync process. And it is a real pain to make the app sources compile again without your IDE working. Am I doing something wrong here? Is this just a plain (known?) bug that needs to be fixed in the gradle plugin? Or does it work as designed due to some multi platform requirements? I’d be thankful if anyone could shed some light on that issue.
👀 1
One more data point. I am using ksp and followed this page to set it up: https://kotlinlang.org/docs/ksp-multiplatform.html There it mentions to put a dependency on commonMainMetadata so maybe that’s related to my issue? Why we need a dependency on commonMainMetadata is unclear and has also been questioned here: https://kotlinlang.slack.com/archives/C3PQML5NU/p1710447465610489
g
Hi, I encountered the same issue in the past. I never managed to find a way to solve it. Just letting you know, you’re not alone here
gratitude thank you 1
u
Did you have ksp set up when that happened?
g
Yes, as soon as I added KSP I started having similar problems
u
Let me try crossposting to #ksp
t
that sounds not right. Can you share more details like logs / tasks / errors or a project for reproducing the issue?
Also, can you try to remove the
kspCommonMainMetadata
to see if the problems remains?
u
completely removing ksp does not help. Guess I have to look into other directions. Btw. I am using include builds. Maybe that’s a hint.
Ok, I did some more investigation and removed all plugins from main build and includeBuild except kotlin multiplatform • Introducing a syntax error in any of the includeBuilds commonMain kotlin source files will still break ide sync • Introducing a syntax error in any of the includeBuilds platform specific xxxxMain kotlin source files will not break ide sync • Introducing a syntax error in any of the main app’s commonMain kotlin source files will not break ide sync • Introducing a syntax error in any of the main app’s platform specific xxxxMain kotlin source files will not break ide sync So this is either a kotlin multi platform + includeBuild issue or just an includeBuild issue
I found the cause: Having a main kotlin multi platform project with an includeBuild kotlin multi platform library. Then setting
kotlin.mpp.enableCInteropCommonization=true
on the main project will cause the task
compileCommonMainKotlinMetadata
to run on the includeBuild during IDE gradle project sync and thereby causes the sync to fail on all errors in the kotlin code
Is this the wrong channel? Is Jetbrains reading here? Could some one comment if this is a known issue? A new bug to report? Or works as designed?
I found the cause:
Having a main kotlin multi platform project with an includeBuild kotlin multi platform library. Then setting
kotlin.mpp.enableCInteropCommonization=true
on the main project will cause the task
compileCommonMainKotlinMetadata
to run on the includeBuild during IDE gradle project sync and thereby causes the sync to fail on all errors in the kotlin code (edited)
Here is a reproducer:
https://github.com/uluckas/SyncIssueDemo