Tue
4
Aug '09
Android scripting environment supports JRuby
by Frank Spychalski filed under android, Ruby

Quite some time has passed since the last time I wrote something on this blog, mostly because I did little non-work related worth mentioning.

But last week I helped Damon to finally support JRuby on his Android Scripting Environment (ASE).

  • Downloaded JRuby sources (jruby-1.2.0RC1) from http://www.jruby.org/download.
  • Patched the build.xml to not include doc/index.html from dynalang.jar otherwise dx will complain about an HTML page in the ruby-complete.jar.

    $ diff -r jruby-1.2.0RC1 jruby-1.2.0RC1.patched/
    Only in jruby-1.2.0RC1.patched/: build
    diff -r jruby-1.2.0RC1/build.xml jruby-1.2.0RC1.patched/build.xml
    42c42
    <
    ---
    >
    238c238,240
    <         <zipfileset src="${build.lib.dir}/dynalang-0.3.jar"/>
    ---
    >         <zipfileset src="${build.lib.dir}/dynalang-0.3.jar">
    >           <exclude name="**/doc/index.html"/>
    >         </zipfileset>
    268c270,272
    <         <zipfileset src="${build.lib.dir}/dynalang-0.3.jar"/>
    ---
    >         <zipfileset src="${build.lib.dir}/dynalang-0.3.jar">
    >           <exclude name="**/doc/index.html"/>
    >         </zipfileset>
    387c391,393
    <         <zipfileset src="${build.lib.dir}/dynalang-0.3.jar"/>
    ---
    >         <zipfileset src="${build.lib.dir}/dynalang-0.3.jar">
    >           <exclude name="**/doc/index.html"/>
    >         </zipfileset>
  • Downloaded the JSON sources from http://rubyforge.org/frs/?group_id=953 and put them in lib/ruby/1.8/json/
  • Copied android.rb to lib/ruby/1.8/.
  • Built jar-complete (ant jar-complete) and added jruby-complete.jar to eclipse project.
  • Connected the bits and pieces in com.google.ase.interpreter.jruby

    But beware! The new ASE apk is HUGE (4.6M) and JRuby is fairly slow. But it works ;-)



7 Responses to “Android scripting environment supports JRuby”

  1. 1

    Hey! This is really exciting!

    As I mentioned in my comment on my blog, I’m also interested in making it possible to build applications entirely in Ruby. That will take some work on compilation and optimization, along with a bit of ingenuity, but I know it’s possible. I’m hoping we can collaborate on that, so that Ruby becomes another first-class language for app development on Android. Feel free to drop me an email, or better yet, join the JRuby dev list and we can start a public discussion about it there.

    Great work :)

    Charles Oliver Nutter (August 4th, 2009 at 08:00)
  2. 2

    Nice work. Any plans to use 1.3.1 rather than 1.2? Plus I believe Charlie Nutter has been working on a more minimal JRuby profile, to reduce the size of jar needed…

    James Abley (August 4th, 2009 at 08:23)
  3. 3

    How does this compare with this http://code.google.com/p/android-ruby/, (which is not using JRuby, but just Ruby)?
    Is there any hope of doing and GUI programming with ASE? Is it possible with android-ruby? android-ruby seems like a project that has not gone anywhere? I just can’t find enough info. Someone in the comments at ASE was saying JRuby would be way too slow due to the was JAVA has no JIT compiller and therefore languages that are just cross compiled c, like ASE Python would fare much better.

    I would love to write GUI apps for Android using Ruby.

    Jason Buchheim (August 31st, 2009 at 16:14)
  4. 4

    Hi Jason,
    you are absolutely right, a cross-compiled CRuby is probably a lot faster. This was one approach I tried but I’m just not that much into cross-compiling and C so I coulnd’t get it to run. I haven’t tried android-ruby but adding support for yet another language is really easy (Damon did a damn good job!) and if I find the time I can add it to ASE. One thing ASE does that android-ruby doesn’t (I think, just quickly scanned the page) is the interface to Android-land. It’s very convenient to scan a barcode etc., and I guess if you want to write an Ruby application on Android, this is a must have…

    Frank Spychalski (September 4th, 2009 at 14:11)
  5. 5

    I am SO interested in developing Android applications with ruby.

    http://code.google.com/p/android-scripting/source/browse/trunk/jruby/ase/android.rb

    Broken link!

    I really want to give this a go, I’m a new droid owner and I have been coding ruby since 2005.. gmail/gtalk me [email protected]– ( remove dashes) and I’m on freenode irc as oneman / oneman_

    I’d be willing to betaboy this stuff and provide as much feedback as possible.

    Cheers,

    David

    David Richards (November 8th, 2009 at 07:47)
  6. 6

    David, just install ASE and you are ready to run Ruby. Please let me know how the performance is on the Droid. On a G1 start-up time for JRuby is an issue, it’s really slooooow.

    Frank Spychalski (November 21st, 2009 at 00:45)
  7. 7

    I am very interested in using JRuby in Eclipse with the Android plugins. I personally don’t see much value in coding command line scripts directly on Android, given the limitations of the keyboard on my ADP2! Can anyone point me to the instructions for installling JRuby in Eclipse which will target Android?

    Ken Burgett (July 25th, 2010 at 01:49)

Any comments? Or questions? Just leave a Reply: