Getting started

jberkel edited this page Apr 29, 2013 · 14 revisions

Getting started

The basic requirements are obviously sbt (0.12.0+) and the Android SDK (brew install sbt android-sdk when using homebrew on OSX).

Using a giter8 template is the easiest way to create a new project that uses the plugin. If you don't have giter8 installed:

$ curl https://raw.github.com/n8han/conscript/master/setup.sh | sh
$ ~/bin/cs n8han/giter8

Now create a new project with one of the Android templates:

$ ~/bin/g8 jberkel/android-app  # append '--branch snapshot' to use the snapshot version  

This will prompt you to customize a few values (press enter to accept defaults), then create the project structure and all needed files plus skeleton tests, specs and activities.

Then, to build the Android package:

$ cd <your app name>
$ export ANDROID_HOME=/path/to/sdk # or ANDROID_SDK_{HOME,ROOT}
$ sbt 'gen-idea no-classifiers' compile # to generate IntelliJ specific configuration
$ sbt # enter sbt's interactive mode

> android:package-debug

Start an emulator (if not already running)

> android:emulator-start <my_avd>  # use <tab> to get a list of avds

To install and start the main activity in the Android Emulator

> android:start-emulator

To build a signed package for release into the Marketplace:

> android:prepare-market

##Launching the emulator from sbt

A developer can now fire up the Android Emulator from the sbt terminal (hint: you can get a list of all avds with tab completion)

> android:emulator-start <my_avd>

To list all devices or emulators

> android:list-devices

To stop the emulator:

> android:emulator-stop

Add plugin to an existing project

Add the following to project/plugins.sbt:

Released version

resolvers += Resolver.url("scalasbt releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)

addSbtPlugin("org.scala-sbt" % "sbt-android-plugin" % "0.6.2") 

Snapshot version

resolvers += Resolver.url("scalasbt snapshots", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots"))(Resolver.ivyStylePatterns)

addSbtPlugin("org.scala-sbt" % "sbt-android-plugin" % "0.6.3-20130429-SNAPSHOT") 

Additional configuration for IntelliJ IDEA (tested on 11.1.1)

Create initial IDEA config files (using https://github.com/mpeltonen/sbt-idea)

$ sbt 'gen-idea no-classifiers'

Then you need to remove the first content root of the test module: http://cl.ly/1x3Y2i2Q1B2a0x083h1i (not sure why this gets added)

Then you need to adjust the android facet settings: http://cl.ly/3P3O0M0U3x3q2k1K0Q3R

Eventually it should look like this: http://cl.ly/3Y132C3c240I1t1S1c1f

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.