-
Notifications
You must be signed in to change notification settings - Fork 94
Working with Android library projects
levinotik edited this page Jan 31, 2013
·
2 revisions
To build a multi-project build, the simplest way is to create a wrapper directory which contains your application and android libraries as sub-directories. For example:
-
- root-project (wrapper/meta project)
- `- myandroidappproject (your actual android application project)
- `- menu-drawer-library (android library-project)
Next, create a Build.scala
inside of root-project/project
. The root-project/project/Build.scala
should look like this:
import sbt._
import sbt.Keys._
import AndroidKeys._
object MyProjectBuild extends Build {
// meta project
lazy val root = Project(id = "meta-project", base = file(".")) settings(
packageT in Compile <<= packageT in Android in myproject,
packageRelease <<= packageRelease in Android in myproject,
packageDebug <<= packageDebug in Android in myproject
) aggregate(myproject, menuDrawerLibrary)
// android application project
lazy val myproject = Project(id = "myproject", base = file("myandroidappproject")) settings(
appSettings:_*
)
val menuDrawerLibrary = Project(id = "menudrawerlibrary",
base = file("menu-drawer-library")) settings(
AndroidSdkPlugin.androidBuildSettings: _*)
lazy val appSettings = AndroidSdkPlugin.androidBuildSettings :+
(name := "myawesomeapp") :+
(compile in Compile <<= compile in Compile
dependsOn(packageT in Compile in menuDrawerLibrary))
}
Don't forget to add the Android Library project to your project.properties
, e.g. android.library.reference.1=../menu-drawer-library
NOTE: you should use the SBT console from the root project directory in order to build your Android application. Simply prefix the Android commands with your application's id:
myproject/android:run
See the README for links to more examples of complex builds.