Developing for Android

Developing for Android

Status Quo

Android applications are self-contained, there appears to be no way for users to deploy a shared library to a device.

The Scala library therefore needs to be embedded in every Android application that uses it.

The Scala nature can be successfully added to an ADT project.

Using ProGuard is highly desirable, to keep these apps to a manageable size.

Prerequisites

You have installed Eclipse, the Android SDK, and ADT.

You have been able to deploy a Java application to an Android device (physical or virtual).

You have installed the Scala-IDE that matches your version of Eclipse.

Step 1: Install AndroidProguardScala

(Collect underpants.)

AndroidProguardScala is an Eclipse plug-in that automates the process of determining the parts of the Scala library your application needs, creating a .jar, and including that in your .apk file. It is written by James Moore and maintained at https://github.com/banshee/AndroidProguardScala. You should follow the directions in the README to add the plug-in to your Eclipse installation.

Step 2: Enable Scala and AndroidProguardScala

(???)

Open an Android project.

Right-click the project and choose Add Scala Nature (which may be under the ‘Configure’ sub-menu).

After a successful build, right-click the project and choose Add AndroidProguardScala Nature.

Step 3: Develop for Android using Scala

(Profit!)

You can now use Scala or a Scala/Java mix to develop your Android project. Builds occur normally, either in the background or on-demand, through the normal Eclipse machinations. You can use the Run menu to do testing and debugging just as you could before you enabled Scala. As an example, here is the Android application generated by ADT rewritten in Scala: