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 Scala Hello 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.
git clone https://github.com/taig/scala-on-android-skeleton.git . && \
sudo rm -r .git/
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.
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.
To install Android SDK Plugin for SBT globally, create the file
~/.sbt/0.13/plugins/android.sbt (the name is arbitrary) and insert
addSbtPlugin( "com.hanhuy.sbt" % "android-sdk-plugin" % "1.5.7" ).
echo 'addSbtPlugin( "com.hanhuy.sbt" % "android-sdk-plugin" % "1.5.7" )' > ~/.sbt/0.13/plugins/android.sbt
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.
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.