Issue
I am trying to use vscode to coding with kotlin. After installing kotlin language and code runner extensions on vscode and install kotlin by snap on my mxlinux:
alt@mx:~
$ snap list
Name Version Rev Tracking Publisher Notes
core 16-2.51.4 11606 latest/stable canonical✓ core
kotlin 1.5.30 61 latest/stable jetbrains✓ classic
alt@mx:~
alt@mx:~
$ snap version
snap 2.51.4
snapd 2.51.4
series 16
debian 10
kernel 4.19.0-17-amd64
alt@mx:~
I wrote this code on vscode:
fun main(args: Array<String>) {
var string = "Hello Students!"
val age: Int = 23
println(string)
println(age)
}
and run I got result and error:
[Running] cd "/mnt/Project/Android/Practise/Kotlin/Practices/tuto1/" && kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar && java -jar HelloWorld.jar
HelloWorld.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
^
Hello Students!
23
[Done] exited with code=0 in 12.147 seconds
And In Ide there are a lots of error:
Solution
and run I got result and error
That is not an error. As it clearly says, it is a warning. Warnings don't stop your code from compiling and running. If you don't want the warning, you can pass the -nowarn
compiler option to kotlinc
. If you do want the warning to stop your code from compiling, pass -Werror
instead. See list of compiler options here.
And In Ide there are a lots of error
From the description of the Kotlin VSCode extension, you are supposed to open a Gradle/Maven project (see my answer here for how to create one), and "support for Kotlin source files with a standalone compiler is experimental". I've also found this issue that points out that even if you don't use Gradle or Maven, you still have to open a folder.
So rather than opening the file like this:
$ code MyProject/HelloWorld.kt
You should open it like this:
$ code MyProject
In other words, open the folder that contains the kotlin file.
Answered By - Sweeper
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.