Project setup

There is a variety of possibilities to set up your project. None of which is as straight forward as one might would expect. It is recommended to use the starter tempalte from GitHub that was created as part of this documentation.

GitHub starter template

The easiest and also recommended way to get started, is to clone the Hello Scala! and remove the .git/ folder. It contains a basic ScalaHello World configuration and is all set up, tweaked and documented to be used with the Android SDK Plugin for SBT. It is definitely easier to start with this project and to gradually remove or change settings which don't apply for your setup than starting from scratch and figure it all out by yourself.

If you now plugin in your development device or launch an emulator, you should execute sbt run to see if your configuration is working. If so, the application should show up on your screen after a little while.

gen-android

The Android SDK Plugin for SBT comes with a sbt task that works similar to Android's create project command. Using this approach has the advantge of automatically targeting your installed Android SDK installation. But to use it, it is necessary to install the plugin to the global sbt configuration. Then sbt will load the Android SDK Plugin for SBT on every usage, even if the project is unrelated to Scala on Android. This allows you to access the custom Android SDK Plugin for SBT commands (such as gen-android) before the project has actually been created.

Now, if the Android SDK Plugin for SBT is available in the global sbt context, navigate to an empty application folder and run the gen-android <platform-target> <package-name> <name> command.

sbt "gen-android android-23 org.example id"

This will create a very basic Java setup, consisting of an example activity and a corresponding test class, some resources and the sbt configuration. All arguments are compulsory, but it looks like the last parameter <name> does not have an effect on the setup process.

Please make sure that the generated ./project/android.sbt file remains in working order. It contains the dependency to the Android SDK Plugin for SBT which you don't nececcarily need, because you are already depending on it via the global configuration, but it is crucial for others to run your project.

giter8

giter8 is a command line utility that scaffolds projects from special GitHub repositories (so-called templates). It is written in Scala and leverages some sbt features, but it may generally be used to scaffold any kind of projects.

There are a couple Scala on Android templates available on the giter8 templates page, they don't seem particularly well maintained and up to date, though.