Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!") }

that's the image of what i tried to debug + ERROR

like image 967
Armin Avatar asked Sep 22 '26 22:09

Armin


1 Answers

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
like image 112
Sławomir Kwaśniak Avatar answered Sep 24 '26 17:09

Sławomir Kwaśniak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!