'Kotlin Debugging doesn't start in visual studio code
I'm new to Kotlin programming language. so... i have downloaded a few extensions such as Kotlin, Kotlin language,Kotlin Formatter, and when i press F5 it gives an ERROR...just one important question which is, should i use another IDE like intellij ?? because i don't really wan't to spend my time on fixing problems, also my computer can't handle android studio so it's between intellij and Vscode. Error in the link below:
fun main(args: Array<String>) {
println("Hello World!")
}
Solution 1:[1]
Of course you can debug your Kotlin code in Visual Studio Code. No need for IntelliJ or Android Studio.
To enable debugging in VS Code, you should install the Code Runner extension https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner and should have the Kotlin command-line compiler installed and configured in your system as well: https://kotlinlang.org/docs/command-line.html
See the pages below for further, detailed infos: https://formulahendry.wordpress.com/2017/05/21/code-runner-supports-kotlin-in-visual-studio-code-now/ https://dev.to/mwrpwr/learning-kotlin-programming-with-visual-studio-code-5e29 https://medium.com/@agavatar/programming-with-kotlin-in-visual-studio-code-1d745d6b4ad1
Solution 2:[2]
I also had a hard time with setting up the debugger, and what worked for me was to checkout a template repository from https://github.com/fwcd/kotlin-quick-start and add the following debug configuration (.vscode/launch.json):
{
"version": "0.2.0",
"configurations": [
{
"type": "kotlin",
"request": "launch",
"name": "Kotlin Launch",
"projectRoot": "${workspaceFolder}",
"mainClass": "quick.start.AppKt"
}
]
}
As a bonus, Gradle is set up then, and one can build, run, and test the app out of the box.
Prerequisites
In VS Code I have installed the following plugins:
- https://marketplace.visualstudio.com/items?itemName=fwcd.kotlin
- https://marketplace.visualstudio.com/itemsitemName=mathiasfrohlich.Kotlin
- https://marketplace.visualstudio.com/items?itemName=naco-siren.gradle-language
And I have installed the following packages locally:
snap install openjdk
snap install --classic kotlin
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pholpar |
| Solution 2 |
