Wednesday, May 30, 2012

Scala Programming for Android


I have followed the tutorial at Scala and Android with Scala 2.7.3 final. The resulting Android App works but even the most basic application takes several minutes (!) to compile and needs 900 kb compressed, which is a show stopper for mobile applications. Additionally, the IDE runs out of memory every now and then. I assume dex is not made for big libraries like the scala-library.



So my question is: Has anyone actually done this and is there any cure for this?


Source: Tips4all

5 comments:

  1. I've written some basic Android applications in Scala, nothing too epic. Not being a Java programmer I was suggested to use a "treeshake", I was explained by a friend that this strips out all the unnecessary libraries from the jar files.

    I have not documented it, but I found that someone else already has:

    http://chneukirchen.org/blog/archive/2009/04/programming-for-android-with-scala.html

    Proguard is not the only solution, you might find something that suits your work flow or is more suited for your environment.

    ReplyDelete
  2. You can now use the Android plugin for Gradle to create Android applications in Scala. It incorporates the ProGuard tool to trim the fat from the resulting APK file, so seems to meet your needs.

    http://wiki.github.com/jvoegele/gradle-android-plugin/

    ReplyDelete
  3. There is also an plugin for the Scala-based builder sbt: sbt-android-plugin.

    ReplyDelete
  4. For tutorials and examples, see also Stéphane Micheloud's "Exploring Android" page: http://lamp.epfl.ch/~michelou/android/

    ReplyDelete
  5. Myself, I've tried all of the above suggested methods with little success. So I decided to modify the examples on Stéphane Micheloud's page and came up with a solution that works (at least on my Windows 7 machine).

    You can find the needed files and instructions at: http://insella.se/blog/scala-on-android/

    ReplyDelete