This is the first in a series of blog posts about getting started with
Android, Scala, IntelliJ and simple-build-tool. Hopefully
this will help people who are interested in building Android apps, but don't
want to write Java get started. Also, if you're already building Android
apps, but would like a more expressive language while staying close to the
metal then Scala is a great alternative to Java. By the end of this series,
you should be able to build, deploy and package your Scala Android apps both
from the command line and IntelliJ. My primary development environment is
Ubuntu Linux but I will provide platform specific instructions where
appropriate. These instructions assume that you have Java 1.6 installed and
its environment variables setup. We'll be putting everything (except for
IntelliJ on Windows and OSX) into the same directory on your system. On my
development machine that directory is /home/jbrechtel/opt. Throughout this
post I'll refer to this directory as $opt. I would suggest the following
locations for $opt, by platform

Now, that’s it for Scala. You should now be able to start a command prompt on
your OS and type ‘scala’ to get a handy Scala REPL for testing things out.

Getting IntelliJ IDEA

Next we’ll get our IDE. IntelliJ IDEA has pretty
good Scala support though it’s not without its flaws as we’ll see throughout
this series. First, point your browser at
http://www.jetbrains.com/idea/download/index.html and download IntelliJ
for your platform. As of version 10.0 the Community Edition (read: Free) of
IntelliJ IDEA supports both Android and Scala development. For great justice!
Install the IntelliJ IDEA package. For Windows and OSX, IntelliJ installs
like a normal application which I presume you already know how to do. For
those of you on Linux:

Extract the tar.gz for IntelliJ to $root/opt/idea

To launch IntelliJ just execute $root/opt/idea/bin/idea.sh

I suggest creating a menu shortcut in Gnome, KDE, or XFCE to the idea.sh
script. There are a number of IntelliJ icons in that bin folder which you can
use for the menu icon. The files are named idea_CE{16-128}.png.

Getting the Android SDK

Let’s go get the Android SDK. Obviously we need this to build
Android applications. We’ll only be grabbing the Android 2.1 platform here,
but the Android SDK manager makes the other platform versions easy to get and
install. The Android SDK can be found here:http://developer.android.com/sdk/index.html.
Download the package for your platform from that site.

Note for Windows users: It looks like Google
has made things easier on you by providing an installer. I’m not familiar
with the installer, but it probably does everything you need it to do.
However, the instructions below are written with the zip package in mind.

Extract the downloaded file to $root/opt/android-sdk

Set the ANDROID_SDK_HOME environment variable to $root/opt/android-sdk

See the ‘Getting Scala’ section above for instructions per platform.

Launch the Android SDK Manager

Linux: $root/opt/android-sdk/tools/android

OSX: $root/opt/android-sdk/tools/android

Windows: $root/opt/android-sdk/SDK Manager.exe

The Android SDK Manager is used to download the various Android platforms and
other third party addons such as the Google Maps SDK and the Samsung Galaxy
Tab SDK. For now we're just concerned with the Android 2.1 platform. Once the
SDK Manager is running follow these steps:

Click 'Available Packages'

Expand 'Android Repository'

Check the box that says 'Android SDK Tools, revision 7'

Click 'Install Selected'

Click 'Accept All' to accept all licenses

Click 'Install'

Now the SDK Manager will download the Android 2.1 platform (also known as
revision 7 or API Level 7 in Android parlance). If you receive a prompt about
ADB needing to be restarted then just click ‘Yes’. Afterwards you can close
any dialogs and the SDK Manager. Once that is complete, move on to the next
section.

simple-build-tool

simple-build-tool / SBT is a (as the name
suggests) build tool for Scala. It provides all the things you might expect
from a modern build system such as:

simple-build-tool is installed according to the instructions on their site

jberkel’s android-plugin for SBT

Next time we’ll cover creating the Android SBT project using jberkel’s
fantastic android-plugin and also doing things like deploying the app to your
phone and packaging it for the market. In the third post we’ll talk about
setting up IntelliJ to edit the code in that project and launch your SBT
targets. In the final post of this series we’ll go over how getting started
unit testing in IntelliJ with ScalaTest. See you next time