Kotlin Debugging doesn't start in visual studio code

Viewed 1660

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

3 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:

And I have installed the following packages locally:

snap install openjdk
snap install --classic kotlin

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

Yes. You can proceed with intellJ. There is first priority i.e. Android Studio but as you mentioned it can not be handled, so you can use IntelliJ. The advantage of Intelli J it provide by default support files and libraries for Kotlin Development so you don't need to install external extension.

he Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.

For more info please visit official website https://www.jetbrains.com/idea/features/

Related