Slick 3.1.1 sqlite java.lang.ClassNotFoundException

时间:2016-08-14 16:19:53

标签: android scala sqlite jdbc slick

我正在尝试连接sqlite数据库和Slick 3.1.1,在Android开发中使用Macroid for Scala。

这是我的代码:

lazy val db = Database.forURL(
url = "jdbc:sqlite:" + getApplicationContext().getFilesDir() + "events.txt",
driver = "org.sqlite.JDBC")

dbSetupAction()

dbSetupAction:

  def dbSetupAction() = {

    val initActions = DBIO.seq(
      events.schema.create
    )

    val futureInitActions = db.run(initActions)

    futureInitActions.onComplete {
      case Success(s) => Log.d("FICHEROS Success", s.toString)
      case Failure(ex) => Log.d("FICHEROS Failure", ex.toString)
    }


  }

活动类:

class Events(tag: Tag) extends Table[(Int, Int, Double)](tag, "EVENTS"){
  def id = column[Int]("ID", O.PrimaryKey, O.AutoInc)
  def eventType = column[Int]("EVENT_TYPE")
  def timeTag = column[Double]("TIMETAG")

  def * = (id, eventType, timeTag)

}

我得到的输出错误是:

  

D / FICHEROS失败:java.lang.ClassNotFoundException:org.sqlite.JDBC

在我的build.sbt中,我添加了:

  libraryDependencies ++= Seq(
  aar("org.macroid" %% "macroid" % "2.0.0-M4"),
  aar("com.android.support" % "support-v4" % "21.0.0"),
  "org.xerial" % "sqlite-jdbc" % "3.8.11.2",
  "com.typesafe.slick" %% "slick" % "3.1.1",
  "org.slf4j" % "slf4j-nop" % "1.6.4")

提前致谢。

1 个答案:

答案 0 :(得分:0)

proguardOptions += "-keep class org.sqlite.JDBC { *; }"