tags:

views:

232

answers:

3

I was thinking of building an app on android with Scala instead of the regular Java (or the equivalent I guess). Is it worth it? Any problems and unnecessary headaches?

A: 

I have been trying to use Scala for Android, but couldn't found appropriate IDE. That was main issue. Existing NetBeans scala plugin is too buggy.

barmaley
Was it buggy because of scala, or because of scala with android specifically? Scala works pretty well with IDEA. I never liked Eclipse or Netbeans personally
egervari
Buggy Scala plugin for Netbeans. About IDEA support of SCALA never knew - I will try how it's
barmaley
+10  A: 

Working with Scala should be mostly painless, as the dex compiler just works with bytecode - which is exactly what Scala produces.

Your biggest problem then is the dependency on scala-library, as dex expects everything to be in a single Jar. This is best handled with Proguard (which will also remove unused code and give you a smaller executable, ideal for mobile)


Current best practice is to use SBT with the Android plugin; It'll take care of everything for you: http://github.com/jberkel/android-plugin

If you must use Eclipse and the plugin supplied by Google, then you're going to have a non-standard directory structure. I also wrote an article on how to deal with this: http://www.assembla.com/wiki/show/scala-ide/Developing_for_Android

But be warned... it takes a lot more effort that way!

Kevin Wright
The main problem is those library use reflection (something like myClass.getMethod()), because proguard can not detect them, you need declare to keep those class/function manually. And some library just hard to make it work with Scala/Proguard/Android, ex. gdata-java-client. Or you need some tweak to keep cenrtain files after proguard process the JAR, eg. ical4j. Otherwise, libraries usually could work with this combnation very easily.
Brian Hsu
This is true! Be wary of reflection...
Kevin Wright
+3  A: 

We discussed this at Scala Lift Off London last Friday and the consensus seemed to be that it generally works fine as long as you avoid Actors. Also, the sbt-android-plugin was highly recommended. Nathan Hamblen's blog has many posts on Android and the ones also tagged Scala have a lot of gotchas worth looking out for.

pr1001
http://code.technically.us/post/824974287/rewiring-android-for-type-safe-layout-resources is a cool (if minor) advantage to programming for Android in Scala instead of Java.
Ken Bloom