10

I'm not an android developer nor a java expert but I've been searching a lot for developing android apps using Scala lately. I found some things like Scala on Android and also a lot of questions and answers here as well but most of them are outdated (they're mostly between 2013 to 2017). Also, Scala on Android's last release was in 2017. So, I guess there wasn't a really big improvement there.

I read somewhere that the main issue is lambda expressions in java but that make no sense. What is the real reason that holds developers from using Scala in android?

I know that Kotlin is the preferred way to develop android but is there any way to develop the whole app in Scala? Is it even possible? if it is, is it a good idea?

What about Scala 3? Is there any hope that the new version of Scala have a future for android development?

1
  • 1
    I wish I could upvote this question twice. I hope someone writes a good answer - I'd like to know the answer too. Commented Oct 20, 2021 at 22:26

1 Answer 1

5

The broad reason is that the maintainers of the official Scala compiler made a decision to only emit bytecode targeting Java virtual machine versions for which Google did not (at the time) support compiling into Dalvik. (The Oracle v. Google legal proceedings may have influenced Google's decision).

In the interim, Google has added support for some Java 8 features. However, the support is not complete, and Scala uses some features which Google's tooling doesn't support.

This scala-lang.org discussion covers some of the major hoops which had to be jumped through to build an Android app in 2.13; it included patching the Scala standard library in order to make the collections work. It does look like there's a chance Scala 2.13.7 will be patched to address at least some of the issues.

In the meantime, the historical Scala on Android project had largely been abandoned; there is apparently the beginnings of an effort to begin a new project based on Scala 2.13 and Scala 3.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your answer, it helped a lot but I don't think some JVM versioning issue stops a powerful functional programming language for android development. Kotlin is something like a beautiful java, as I understood (Correct me if I'm wrong please, I'm not a Kotlin guy!). Also, Scala is scalable and I think it will have a huge impact on both small and large applications.
Scala is scalable but not in that sense )) I think compiled Scala tends to be somewhat bigger and slower than Java - lots of really small classes. Negligible for backend, but I am not sure it's the best fit for mobile development
It's not really the versioning, per se. Android doesn't support all of the Java VM/Java platform. A program which ends up using the parts which Android doesn't support will not work on Android. For whatever reason (performance?) Scala's standard library uses some of those parts. Is it fixable? Yes, most likely via adding a fourth compilation target: JVM, JS, Native, and Android (it would be interesting to directly compile to Dalvik, actually...). Is that an effort in which the core team is interested in expending effort? Maybe not, but it's open source...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.