开发者

Scala, Android and Eclipse

开发者 https://www.devze.com 2023-04-11 10:19 出处:网络
I\'ve started learning Scala, and I... I think I\'m in love. I\'ve only coded small test snippets so far, but since I currently working in Android development, what I really want to do is try my hand

I've started learning Scala, and I... I think I'm in love. I've only coded small test snippets so far, but since I currently working in Android development, what I really want to do is try my hand at writing Android applications in Scala.

I've found articles and qu开发者_如何转开发estions on the matter, but mostly referring to older versions of the three tools (Android SDK/Scala/Eclipse), so the general question is:

Is anybody coding Android apps in Scala right now, with the latest SDK, Scala 2.9 and Eclipse Indigo? How viable is it?

And, in particular:

  1. How's the interaction/integration between Scala's features and the Android library?

  2. What's the state of the Scala plugin for Eclipse? I've read all the features you'd expect are there, but I'd like to know first-hand stories, specially about the debugger.

  3. How well does the build process (scala to java to dalvik, ant, proguard, etc.) automate?

Thanks!


We are using Scala heavily to test our Android code - you can read a writeup of how we're doing so here. We use Ant or SBT to compile - there's an excellent SBT plugin for Android development.

Having said all of that, I'm not sure that I would recommend Scala for production Android development. In particular Scala 2.9.x is basically unusable as there is no good way to get the libraries to work on Android. You can read about the issue here.

It's a real pity, as Android development would benefit considerably from Scala if we could get it working properly.


Solution found here to use the latest Android SDK, with Eclipse 3.7.2 and Scala 2.9 :

https://stackoverflow.com/a/11084146/1287856

  1. It completely handles the android library
  2. You can make Android Library out of scala projects as usual
  3. The build process is completely automated, including proguard-ing and exporting the project with the regulard Android tools.


I started to implement the android application (a twitter client) from the book "Learning Android" with Scala 2.9.0-1 a while ago.

In my opinion you can use it. I had only one problem with the parameter list at AsyncTask (see this link, problem #3). If you want to checkout out the project, you can find it here.


This video from ScalaDays 2011 may be hepful:

Scala on Android: Real-world Experience at Bump Technologies by Michael Galpin

EDIT:

If you really really want to run Scala code on Android (and not really make an app, but for yourself), then I have an easier solution. It depends on if your phone supports the procedure. In summary the steps are:

  1. Install Ubuntu on your device (as described here). This will not affect the Android installation.

  2. Boot Ubuntu, install JDK, Scala, etc, copy your Scala jars and run from there.

0

精彩评论

暂无评论...
验证码 换一张
取 消