Ruboto

Building Android app with Ruby By Yihang Ho

There are many mobile app development frameworks out there. Most of those frameworks attempt to solve one big problem - compatibility across the many mobile platforms. The idea is to write your app once, and compile to run on all (or at least most) major mobile platforms. Personally, I have tried PhoneGap, and also have heard that Titanium is pretty neat too.

Today, I found Ruboto. Ruboto is fundamentally different from PhoneGap and Titanium. Ruboto compiles only to Android. Ruboto is made possible by JRuby, an implementation of Ruby using Java. JRuby allows Ruby code calling Java libraries, and Java code calling Ruby libraries. As such, it is natural to have something like Ruboto.

Installation

The installation process of Ruboto is relatively straightforward:

  1. Get an implementation of Ruby. I guess it makes sense to use JRuby in this case. I strongly recommend using RVM to install and manage various versions and implementations of Ruby.
  2. Get the Android SDK and follow the setup guide.
  3. Apparently you need Android API 10 and Intel HAXM. Installation guide for Intel HAXM (At the time of writing, this guide does not include any instruction for OS X, but the instructions for Windows (surprisingly) work on OS X, too.)
  4. Also, install a newer Android API. I installed Android API 19, which corresponds to KitKat 4.4.2.
  5. Install ANT. (brew install ant if you are using Homebrew.)
  6. Install the jruby-jars gem. (gem install jruby-jars)
  7. Configure the ANDROID_HOME environment variable. (Set it to point to the absolute path of the sdk directory of the Android SDK that you have installed in step 2. Make sure that you are using absolute page, according to the documentation of Ruboto, Java does not expand ~.)
  8. Run ruboto setup to iron out any other problems.

Create an app

Ruboto comes with a code generator. Run

ruboto gen app --package com.example.test --name test --target android-19
cd test
rake

Running rake will build the APK file, which will be located in bin/Test-debug.apk. If you have configured a virtual device, or have connected an Android device to your machine, you can run rake install to install the app.

Caveats

  1. The documentation for Ruboto is incomplete, almost can be considered non-existent. I am still in the process of figuring out the API and stuff like that.
  2. The compiled APK is huge. There are two ways of building your app. The way that we did here will produce a relatively small APK, but it requires another app, Ruboto Core. To avoid this, you can compile your code together with the necessary libraries by using the --with-jruby flag when running the gen app command. The resulting APK is much larger. For this particular example, we have ~9MB vs ~80KB. Also it takes a longer time to compile (2 mins 16 sec vs 8 sec).