Fri
14
Dec '07
JRuby on Android
by Frank Spychalski filed under Ruby, Work, android, google

a red robotToday I tried to run JRuby on Android. I failed. This article is more like a lab report so expect more boring details…

At first I tried the easiest way and added the JRuby jar to my android project. This would have been way to easy and as I expected it did not work.

Then I copied all the JRuby sources into my android project and eclipse gave me more than 100 errors. I had to remove org.jruby.javasupport.bsf.BSFExample and the whole org.jruby.demo package because of dependencies to awt and swing. Now only a single error message was left with a dependency on some class I can’t remember in java.beans. So I downloaded the Java sources and copied the class into my project which gave me a few new dependencies. So I copied the whole java.beans package into the project and removed all dependencies to awt and swing from the code. Now I needed to add only 2 more classed com.sun.beans.ObjectHandler and sun.awt.EventListenerAggregate for eclipse to stop complaining.

a red robotAt this point I encountered my first bug in Android: dx(the compiler for Dalvik) complained about the bsf.jar file which came with JRuby[1]. Fortunately I could work on with the 2.4.0 version of bsf.

At this point eclipse stopped complaining and dx was able to create Dalvik byte code for my test application and package the result.

But when I started the result on the emulator all I got was an exception… This is where I will stop for today and continue whenever I find some time. If someone out there has already successfully used JRuby on Android please leave me a comment on how you managed to do it.

[1] the bug was fixed less than 3h after I reported it. Kudos to the Dalvik team!


5 Responses to “JRuby on Android”

  1. 1

    Hi Frank,

    What was the exception you got on the emulator?

    Jose (December 14th, 2007 at 20:10)
  2. 2

    The Exception was:

    An error has occurred in the process ... Unable to start activity ComponentInfo{...}: java.lang.IllegalArgumentException: can't load Java class file.

    I got that exception at the end of the day so I did not spend more time investigating the reasons but I will next week.

    Frank Spychalski (December 15th, 2007 at 01:10)
  3. 3

    Because some time has passed since I posted this I think a little update is needed. I’m currently not working on this because I noticed that I lack a lot of basic knowledge on Android. But it’s not forgotten. I will pick this project up again as soon as I learned enough about Android.

    Frank Spychalski (January 10th, 2008 at 15:13)
  4. 4

    Any updates?

    Konstantin Haase (December 25th, 2008 at 15:43)
  5. 5

    Sorry, no updates from me. But a colleague cross-compiled Lua (http://www.damonkohler.com/2008/12/lua-on-android.html) and Python (http://www.damonkohler.com/2008/12/python-on-android.html) to run on Android.

    Frank Spychalski (December 25th, 2008 at 15:49)

Any comments? Or questions? Just leave a Reply:

Bad Behavior has blocked 545 access attempts in the last 7 days.