We currently are extensively using Scala to build our app and had to go through some tricky situations to make Scala 2.13 (or Scala 2.12.8 and higher) on android to happen, addressing the following issues
-
Currently Android’s support on JVM 8 and above isn’t perfect, missing ClassValue.java from its package. We had to write own java.lang.ClassValue.java that mimics the behavior to get through it
-
Access to java.lang.invoke.VarHandle.releaseFence() is currently blacklisted on Android, which frequently used by immutable collection classes. We had to modify scala.runtime.Statics.java to do nothing to keep it away from trying to access the method
-
Since currently android only supports MethodHandle.invoke() for API version 26 or higher, we had to set minSdk version to 26
We managed to compile and run our app on Android with Scala 2.13 by troubleshooting the issues above and pretty satisfied with the result.
Will there be any plans to make it easier to deploy Scala on Android in the future? We’d love to keep Scala going for building our App for coming years.