Hey
@Vishnu Shrikar: As a technical lead for multiplatform I can attest you: I indeed feel uncomfortable and stressed when reading such messages and the communication style is certainly not my preferred one, but I feel like you got plenty of rights to complain about your experience!
Not being able to just execute the code from this little ‘run button’ next to you main method really sucks and I am very frustrated that this happened to you. I checked on IntelliJ and it works there (instead of Android Studio), so you might want to give IntelliJ a shot?
Now maybe you’re wondering how something stupid like this can happen in production? If I am frustrated by it, why would I not just ‘go and fix it’?
Let me provide some technical insights on how this bug happened as I feel like its somewhat interesting:
Step 1: Ide Dependency Resolution:
Resolving dependencies for the IDE in multiplatform is much more complex than you might anticipate. Have a read in all the dependency resolvers:
https://github.com/JetBrains/kotlin/tree/master/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/ide
Step 2: Omission of runtime dependencies.
In order to simplify and speedup dependency resolution for the IDE we omitted importing ‘runtime dependencies’. What is a runtime dependency for common/shared code anyways? This concept poorly translates to multiplatform.
Step 3: IntelliJ run configurations
Usually IntelliJ executes jvm code by compiling (mostly with Gradle) and then running it using a process started within the IDE. It uses runtime dependencies to infer the classpath 🌩️ ⚡
Step 4: We found out about this issue
https://youtrack.jetbrains.com/issue/KT-44794/java.lang.NoSuchMethodError-error-for-Compose-generated-code-at-runtime
We therefore implemented a ‘run carrier task’ that allows the IDE to instrument Gradle quickly and execute code:
https://youtrack.jetbrains.com/issue/KT-58661/KGP-KotlinJvmTarget-Implement-run-carrier-task
Step 5: Android Studio vs IntelliJ vs IntelliJ Kotlin Plugin.
Now the support for executing code this way was implemented in the Kotlin IDE plugin and seemed to work fine inside IntelliJ.
However, we do not have sources of Android Studio /master at our hands, nor can we quickly try this out.
Step 6: Now when Android shipped this run carrier task (months later), we saw that it is not working in Android Studio
https://youtrack.jetbrains.com/issue/KTIJ-27797/Android-Studio-Support-Multiplatform-jvm-run-carrier-task
The reason: The run configuration in IntelliJ uses knowledge about Gradle tasks that are not available inside Android Studio (they omit it as optimisation).
Now here we are; Run gutter being broken in Android Studio, timing is not comfortable.
We already work close with Google on resolving this issue.
I hope I was able to restore some of your faith in fellow engineers.
Thanks