Fwd: [scala-lounge] Re: [scala] Scalandroid

Skip to first unread message

David Pollak

Nov 13, 2007, 3:32:49 PM11/13/07
to jvm-la...@googlegroups.com

---------- Forwarded message ----------
From: Matt Hellige <ma...@immute.net>
Date: Nov 13, 2007 12:09 PM
Subject: [scala-lounge] Re: [scala] Scalandroid
To: scala-...@listes.epfl.ch

On Nov 13, 2007 1:02 PM, David Pollak < feeder.of...@gmail.com> wrote:
> The Android VM reads JVM bytecode and converts it into DEX format.
> There's no reason that Android can't run any JVM language unless that
> language is dynamically creating bytecode at runtime (this is a
> questionmark.)  There's a discussion of this issue on the JVM Languages list
> right now.

(moving to the lounge...)

I've actually just tried this. The short answer is that it's going to
take at least a little work, and maybe a lot.

I generated the sample activity using the Android scaffolding scripts,
hacked up the build.xml a little bit and ported the main Activity
class to Scala. Everything compiled fine and installed to the
emulator, but I got denied : NoClassDefFoundError. I figured this is
likely a missing scala-library.jar, so I extracted just
scala.ScalaObject and scala.ScalaObject$class and packaged them up
with my own classes. This fixed the NoClassDefFoundError, but now I
get something worse. The onCreate() method of each activity must call
super.onCreate(). The phone checks for this and throws an exception
otherwise. But if I try to call super.onCreate() in my Scala code,  I
get a NoClassDefFoundError. Of course the same code works fine in
Java. The bytecode looks similar from javap, but clearly there's
something going on.

It might be as simple as writing some wrapper code in Java and then
delegating to Scala, but this makes me worry that the dx compiler does
depend in subtle ways on the bytecode. Unfortunately, I don't have any
more time to play with this today. I'd love to learn that it's
something simple.

Happy hacking...

Matt Hellige / ma...@immute.net

lift, the secure, simple, powerful web framework

Matt Hellige

Nov 14, 2007, 5:36:10 PM11/14/07
to JVM Languages
Thanks for the cross-post! And an update: this exposed a bug in the
Scala compiler, which has now been fixed. So Scala does successfully
run on the Android emulator, although research remains to be done to
determine how much of the standard library will work without


On Nov 13, 2:32 pm, "David Pollak" <feeder.of.the.be...@gmail.com>

> ---------- Forwarded message ----------
> From: Matt Hellige <m...@immute.net>
> Date: Nov 13, 2007 12:09 PM
> Subject: [scala-lounge] Re: [scala] Scalandroid

> To: scala-lou...@listes.epfl.ch

> Matt Hellige / m...@immute.nethttp://matt.immute.net

Reply all
Reply to author
0 new messages