java.lang.NoSuchMethodError: scala.collection.immu

2019-09-01 09:04发布

问题:

I am trying to parse a json String on android using with Scala

override def onCreate(savedInstanceState: Bundle): Unit = {
 super.onCreate(savedInstanceState)
 val jsonStr:String = Source.fromInputStream(getResources.openRawResource(R.raw.catalog)).mkString("")
 Log.i(TAG, jsonStr)
 val result = JSON.parseFull(jsonStr)
 result match {
   case Some(catalog) => Log.i(TAG, catalog.toString)
   case None => Toast.makeText(this, "cannot parse json", 2000).show();
 }
 setContentView(R.layout.activity_grid_view)

}

It compiles fine but when executed on android, it fails at JSON.parseFull with a runtime exception java.lang.NoSuchMethodError: scala.collection.immutable.StringLike.toString

I am using scala 2.10.3

Seems like a bug with scala itself