Scala on Android

The comprehensive documentation

sbt

Scala Build Tool

  • Information reliability Moderate Might become outdated
  • Last edit Fri Jul 10 19:44:32 2015 +0200
  • Edit on GitHub

Installation

To install sbt, download it from the official website and follow the install instructions. The Android SDK Plugin for SBT requires no manual download, but will instead be loaded by sbt as a dependency, which will be explained later. Please make sure to read the excellent article Scala on Android - Setting sbt configuration by 47 Degrees if you are starting from zero.

  • Information reliability Moderate Might become outdated
  • Last edit Fri Jul 10 19:44:32 2015 +0200
  • Edit on GitHub

Structure

A sbt project has the following directory structure:

  1. project-root/
    1. project/
      1. Build.scala

        Your actual build configuration. Here you specify your (sub-) projects, manage application dependencies and configure ProGuard.

        You can also manage your build via /build.sbt. However, /project/Build.scala is written in actual Scala code, is slightly more expressive and allows you to keep all of your configuration files in the /project folder.

      2. build.properties

        An optional, but recommended file that specifies the sbt version for this build.

      3. plugins.sbt

        Dependencies for sbt plugins are managed in this file. This is necessary, as we need to rely on Android SDK Plugin for SBT here.

    2. src/
      1. main/
        1. AndroidManifest.xml
        2. res/

          Common Android resource folders such as drawable/ and values/ go here.

        3. java/

          Java source files that may interact with the Scala sources and vice versa.

        4. scala/

          The actual application code is located in this folder if you're not building a Java app with sbt (which is also possible).

      2. test/
        1. AndroidManifest.xml

          Optional manifest file to use when tests are executed

        2. res/
        3. java/
        4. scala/
      3. androidTest/

        A folder for instrumentation tests.

Further reading

Comments