How to troubleshoot “Error:scalac: bad symbolic reference to scala.ScalaObject encountered in class file 'package.class'”?

对着背影说爱祢 提交于 2020-01-04 04:35:32

问题


I face this error message when I try to run the project:

Error:scalac: bad symbolic reference to scala.ScalaObject encountered in class file 'package.class'.
Cannot access type ScalaObject in package scala. The current classpath may be
missing a definition for scala.ScalaObject, or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.

There are similar questions here and here, but none seems to be applicable to my case - mine isn't spitting out such messages. The only thing I have to go one is scalaObject.

This is a sudden breakage -- the project was made inside IntelliJ IDEA with sbt and ran find until today. Suddenly, it can't find what it needs.

This is the whole build.sbt file:

name := "MyApp"

libraryDependencies ++= Seq(
  "joda-time" % "joda-time"    % "2.3",
  "org.joda"  % "joda-convert" % "1.6",
  "org.scala-lang" % "scala-swing" % "2.9.2",

How do I troubleshoot this?


回答1:


I believe you may have changed sbt.version in project/build.properties or scalaVersion in build.sbt. Or just sbt the launcher. Or the Scala plugin for IntelliJ IDEA. Could that be the case?

I'm basing it on "or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.".

You may want to see update reports in target\resolution-cache\reports.




回答2:


You mentioned that you are using IntelliJ IDEA. I am using the Scala IDE for Eclipse and I ran across this error. It only occurred when I turned off this option in the IDE config:

withVersionClasspathValidator - Check Scala compatibility of jars in classpath

When this option was turned on, I instead got:

mongo-casbah-commons_2.8.1-2.1.2.jar is cross-compiled with an incompatible version of Scala (2.8.1).

I'm new to Scala, but this seems to be because I'm using Scala 2.11.2 to compile, but I'm including a jar that was built using Scala 2.8.1.



来源:https://stackoverflow.com/questions/24643872/how-to-troubleshoot-errorscalac-bad-symbolic-reference-to-scala-scalaobject-e

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!