IntelliJ 中的 Kotlin 未解析引用 [英] Kotlin unresolved reference in IntelliJ

查看:38
本文介绍了IntelliJ 中的 Kotlin 未解析引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用本教程在 IntelliJ IDEA 中学习 Kotlin.
当我尝试运行以下示例时,

I started off with this tutorial for learning Kotlin in IntelliJ IDEA.
When I tried running the following example,

fun main(args: Array<String>) {
    println("lol")
}

构建失败并出现以下错误:

Build fails with the following error:

Error:(5, 5) Kotlin: Unresolved reference: println

这是我第一次使用 IntelliJ.我也从未参与过 Java 项目.我错过了什么吗?

This is the first time I am using IntelliJ. I have never worked on a Java project either. Am I missing something?

我已经看过另一个问题,虽然它不适用于我的情况.

I have already seen this other question, though it is not valid for my situation.

推荐答案

您的 Intellij IDEA 插件和您在项目中使用的 Kotlin 运行时/编译器需要匹配.例如,如果 IDE 插件是 Beta 1,但您的 Gradle/Maven 项目使用 M12,您将遇到与您描述的完全一样的问题.因此,请检查所有内容是否一致.

Your Intellij IDEA plugin and the Kotlin runtime/compiler that you use in the project need to match. For example if IDE plugin is Beta 1, but your Gradle/Maven project using M12, you'll have issues exactly as you described. So check that everything lines up.

如果您仍然有问题,对于一些较旧的插件,您需要清除 Intellij IDEA 中的缓存(文件菜单,清除缓存并重新启动,选择重新启动选项).

If you still have issues, with some older plugins you need to clear the caches in Intellij IDEA (file menu, Clear Caches and Restart, select option to restart).

这篇关于IntelliJ 中的 Kotlin 未解析引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆