i начал изучать котлин несколько недель назад, но оставил его , потому что другие вещи и продолжают сегодня , но кода, это высокая с ошибки , не имеет смысла. Ошибки для всего. < /p>
код: < /p>
fun main() {
val variable:String = "Hello world"
print(variable)
}
< /code>
Сообщение о проблемах в vscode: < /p>
Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library
Unresolved reference: print
Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library
< /code>
Ошибка журнала JSON с помощью vScode: < /p>
[{
"resource": "/home/my_username/programming/courses/kotlin/first.kt",
"owner": "_generated_diagnostic_collection_name_#1",
"code": "MISSING_BUILT_IN_DECLARATION",
"severity": 8,
"message": "Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library",
"source": "kotlin",
"startLineNumber": 2,
"startColumn": 19,
"endLineNumber": 2,
"endColumn": 25
}]
< /code>
[{
"resource": "/home/my_username/programming/courses/kotlin/first.kt",
"owner": "_generated_diagnostic_collection_name_#1",
"code": "UNRESOLVED_REFERENCE",
"severity": 8,
"message": "Unresolved reference: print",
"source": "kotlin",
"startLineNumber": 3,
"startColumn": 5,
"endLineNumber": 3,
"endColumn": 10
}]
< /code>
[{
"resource": "/home/my_username/programming/courses/kotlin/first.kt",
"owner": "_generated_diagnostic_collection_name_#1",
"code": "MISSING_BUILT_IN_DECLARATION",
"severity": 8,
"message": "Cannot access built-in declaration 'kotlin.String'. Ensure that you have a dependency on the Kotlin standard library",
"source": "kotlin",
"startLineNumber": 3,
"startColumn": 11,
"endLineNumber": 3,
"endColumn": 19
}]
< /code>
But this compile and work, without problems in the terminal:
cd "/home/my_username/programming/courses/kotlin/" && kotlinc first.kt -include-runtime -d first.jar && java -jar first.jar
< /code>
Output:
Hello world
< /code>
Use Ubuntu 22.04 and installed kotlin via snap (as indicated in the official website):
sudo snap install --classic kotlin
< /code>
In vscode use the follow extensions that could be implicated in the problem:
- fwcd.kotlin
- mathiasfrohlich.Kotlin
- usernamehw.errorlens
IMPORTANT: The problem isn't the installation of the language itself, since the code compile and run witout problems, and don't throw error in terminal when executed.
Подробнее здесь: https://stackoverflow.com/questions/732 ... in-vs-code
Мобильная версия