Working with the sbt command line

Even though it it possible to configure your IDE to handle some basic tasks such as compiling and running your app, or executing tests, you will eventually fall back to the command line in order to fix build issues or trigger more advanced tasks. It is therefore inevitable to get a basic understanding for the sbt command line.

The interactive sbt shell is started by simply typing sbt and hitting enter in your terminal. Alternatively, to only run a single sbt command, it is possible to pass an argument to sbt, e.g. sbt android:packageRelease.

Common tasks

Below is a list of common and important sbt, and its respective Android plugin, commands.

Command

Description

android:run

Compile the project, package a debug apk and deploy it to an active device or emulator

android:packageRelease

Create a signed apk

android:packageDebug

Create a debug apk

test

Run unit tests and report results

reload

Apply changes that have been made to your sbt configuration

compile

Compile the source code

clean

Remove all compiled and generated code, delete ProGuard cache. This might be useful when experiencing issues with incremental builds.

If you find yourself running a particular android:* task very often, you may want to add a shortcut to your sbt configuration. E.g. run <<= run in Android allows you to trigger the task from the console via run instead of android:run.