1
votes

I'm using intellij to create sbt cross compile platforms project with the following platforms JVM,JS,NativeWin,NativeUbuntu, Android and Shared scala code.I need java 8 in my project and it seems that android doesn't work with java 8 version ,due to I specified 1.7 version in sbt file for android module as follow :

Android module build.sbt file

val commonSettings = Seq(
  version        := "0.0.1",
  scalaVersion   := "2.11.12",
  scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature", "-target:jvm-1.7"),
  javacOptions  ++= Seq("-source", "1.7", "-target", "1.7"),
  exportJars     := true
)

lazy val android = (project in file("."))
  .enablePlugins(AndroidLib)
  .settings(commonSettings: _*)
  .settings(
    name := "sgl-android",
    platformTarget := "android-28",
    useProguard := true
  ) 

Project settings :

enter image description here

I got this error :

Error:java: javacTask: source release 1.8 requires target release 1.8

1

1 Answers

2
votes

Android supports java8, but your code and dependencies libraries should't call MethodHandle.invoke. See https://developer.android.com/studio/write/java8-support . Standard scala libraries 2.11, 2.12, 2.13.0-M5 use this method, therefore compilation is unsuccessful.