SBT + Idea 13 => Cannot resolve symbol

2019-02-04 02:49发布

I'm using SBT + Idea 13.1.1 and I have all my SBT file in red:

name := "Transformer"

version := "1.0"

libraryDependencies ++= Seq(
  "com.github.scopt" %% "scopt" % "3.2.0",
  "org.scalatest" % "scalatest_2.10" % "2.1.0" % "test"
)

It's saying "Cannot resolve symbol ..." name or version... But Seq is ok.
But it's all good to run the app from SBT cmd or even from Idea directly running the main or scalatests.

I know it's not a lot information to troubleshoot but I don't know what to check else. Tell me if you have an idea I'll provide everything.

Cheers

6条回答
爷、活的狠高调
2楼-- · 2019-02-04 03:22

I had a similar problem on 14.1.2; in my case adding

libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.2.1" % "test"

and then trying to

import org.scalatest._

Would resulted in: cannot resolve symbol scalatest

Downgrading sbt (0.13.8 -> 0.13.7); in build.properties solved the problem.

here are more details.

查看更多
Melony?
3楼-- · 2019-02-04 03:23

Had the same problem in IDEA 14.0. Nothing above worked.

Upgrade to IDEA 14.1.1 did the trick.

查看更多
放我归山
4楼-- · 2019-02-04 03:24

To fix this, remove the folder .idea and reimport the project.

The root cause remains a mystery...

查看更多
你好瞎i
5楼-- · 2019-02-04 03:37

I had a similar problem when I updated to SBT 0.13.7. IntelliJ started marking operators such as := and ++ in red with message "Cannot resolve symbol"

My steps to fix this solution were as follows:

  1. In IntelliJ under Files | Settings, I switched my SBT Runner to use a Custom Launcher (and gave my path to sbt-launch.jar which for me was /opt/sbt/bin/sbt-launch.jar).

  2. After testing that I can still compile after #1 above, I then had to invalidate the cache and restart; under Files | Invalidate Caches / Restart...

That's it! :-)

查看更多
做自己的国王
6楼-- · 2019-02-04 03:38

Updating my build.properties from 0.13.8 to a newer version, like 0.13.15, solved it for me. Reference github issue.

查看更多
▲ chillily
7楼-- · 2019-02-04 03:45

Restarting IntelliJ fixed it for me.

查看更多
登录 后发表回答