0. Check Your Android SDK installation

  • Make sure the Android SDK is fully updated (minimum build-tools 19.1.0 and up).
  • Set the environment variable ANDROID_HOME pointing to the path where the Android SDK is unpacked.

1. Download and Install sbt

sbt, the Scala build tool, is required. Follow the instructions on the sbt website to install it.

2. Configure Your Project

Scala’s Android support requires adding sbt-android as a plugin for sbt (Scala’s build tool) to your project configuration. To do that:

  1. Assuming that your project is called my-example-project, create a directory named my-example-project/ and enter it.
  2. Create a file called build.sbt (if it doesn’t exist) inside your my-example-project/ directory and add the line androidBuild to that file.
  3. Create a directory called project/ (or enter that directory if it exists).
  4. Create another file called build.sbt (if it doesn’t exist) inside your my-example-project/project/ directory.
  5. Add the line addSbtPlugin("org.scala-android" % "sbt-android" % "1.7.6") to that file.

3. Create an Android Project

  1. Run sbt.
  2. Inside the sbt shell, execute
    gen-android com.mypackage.test test
    to create an Android project called test which uses version 23 of the Android SDK.

4. Run Your Android Application

android:run builds your application, then installs and runs it on your device.

Done!