at scala project, compiler error - Cannot resolve symbol List?
Solution 1
If your IDEA plugin doesn't see scala classes then go to File -> Project Structure and check the following:
Make sure the Scala Facet is added to your application. Go to the Facets tab and check if Scala facet is listed there. If not, you need to add and configure it. Then make sure that Scala Facet is listed under all the modules that need Scala.
Make sure the Scala Facet uses the right version of your scala library (Idea will mark it with red, if it cannot be found).
Make sure scala-library.jar is on the list of dependencies of the modules using Scala. Check if paths are ok.
Solution 2
For anyone having the same problem, start by trying the following in Idea:
File -> Invalidate Caches -> Invalidate and Restart
catch23
Updated on July 09, 2022Comments
-
catch23 almost 2 years
I'm completely newly at Scala.
I installed java, sbt and scala on Ubuntu 12.04:nazar_art@nazar-desctop:~$ sbt sbt-version [warn] Alternative project directory .sbt (/home/nazar_art/.sbt) has been deprecated since sbt 0.12.0. [warn] Please use the standard location: /home/nazar_art/project [info] Loading project definition from /home/nazar_art/.sbt [info] Set current project to default-5b9232 (in build file:/home/nazar_art/) [info] 0.12.4 nazar_art@nazar-desctop:~$ scala -version Scala code runner version 2.10.2 -- Copyright 2002-2013, LAMP/EPFL nazar_art@nazar-desctop:~$ java -version java version "1.7.0_40" Java(TM) SE Runtime Environment (build 1.7.0_40-b43) Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
I installed scala and sbt plugins to Idea.
And when I tried irst example project I see next error:
Cannot resolve symbol List, after next lines:
package example import common._ object Lists { def sum(xs: List[Int]): Int = { // <== here underline for List if (xs.isEmpty) 0 else xs.head + sumList(xs.tail) } }
I couldn't figure out what exactly is wrong? IDEA suggest me importing
java.util.List
- but this class doesn't have anyisEmpthy()
method.
Any suggestion?- How to solve this trouble?
Update:
- I reinstalled newly version of IntelliJ IDEA 13 Community
Edition
instead of # 12. Untared in
/usr/local/Idea
. - Removed sbt -
sudo apt-get purge sbt
. And reinstall accord this script. -
I went to
/MyProjectDirectory/project/
and created 'plugin.sbt' with content:addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1")
After this I type from my project directory
sbt gen-idea
. It rebuild project for Idea.- And opened this project with idea greeting window (Open Paroject). Of course,
installed
sbt
andscala
plugins.
It should be enough but it shown again:
Cannot resolve symbol List
and suggesting import
import scala.collection.immutable.List
. But this isn't helpful. It keep being underlined with red line. -
catch23 over 10 yearsAt project it doesn't have Scala Facet. How can I configure all this options?
-
catch23 over 10 yearsDoes this Scala IDE has modify eclipse or it keep working correct with java (create java project etc.)?
-
maksimov over 10 yearsYou can install it separately to work exclusively with Scala and Java, or you can add plug-ins to your existing Eclipse. It should not affect your working with Java projects in any way.
-
Piotr Kołaczkowski over 10 yearsGo to Project Structure -> Facets and click the green plus icon - then select Scala. You can also add facets to the modules by right-clicking the module name in the Modules tab.
-
catch23 over 10 yearsIt need to be only untarred?
-
maksimov over 10 yearsYes, there's no install process as such.
-
user1338062 almost 10 yearsI had to wipe out the project/ directory and then reimport to IDEA, that seemed to finally fix the issues.
-
bachr almost 9 yearsScala Facet is replaced with Scala SDK in IDEA 14 blog.jetbrains.com/scala/2014/10/30/…