Tutorial: use ruboto in a legacy app

donv edited this page Sep 12, 2012 · 7 revisions

Goal

Use Ruby in an existing Java-based Android app. Concepts covered:

  • Add Ruboto to the existing app
  • Initialise JRuby in the background.
  • Call your script.
  • Get the results.

Prerequisites

You should have completed the Getting started with Ruboto tutorial.

This tutorial has been tested with the following setups

Platform JDK ant Ruby ruboto RubotoCore Device API level Tester
OS X 10.8.0 1.7.0_07 1.8.2 MRI 1.8.7 0.8.1 0.4.7 HTC Desire HD android-10 donv

Create the app, install, and run it

android create project --path legacy --package org.ruboto.example.legacy --target android-8 --activity LegacyActivity
cd legacy
ant debug install

Find the "Legacy" app on your device/emulator and start it. The app should start up, showing the Java activity with "Hello World, LegacyActivity".

Add Ruboto to the app

ruboto update app --force
rake clean install start

The app should start up just like before, showing the Java activity with "Hello World, LegacyActivity".

Initialize Ruboto at startup

Add your script/class

Call your script

Use the results

Enjoy!

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.