Hi,

I'm learning both Android and Scala.  Now I'm trying to add an ActionBar.

The app works when I use ant.  But when I use pfn's [android-sdk-plugin], the
activity cannot be displayed properly.  ActionBar is displayed but it fills the
whole screen.

Here is how I create an ActionBar app using sbt.




# Using Ant

First, I create a new project "action-bar-demo" in its parent directory 
"mydemo".

    $ mkdir mydemo && cd mydemo
    $ android create project -t android-19 -p action-bar-demo -k 
com.example.actionbardemo -a ActionBarDemo
    $ cd ..

Then I copy v7-appcompat code into "mydemo".

    $ cp -R ${ANDROID_HOME}/extras/android/support/v7/appcompat .
    $ android update lib-project -p appcompat

Set `minSdkVersion` to 7, add a theme, extends
`android.support.v7.app.ActionBarActivity`, and referencing the library
project.

    $ cd action-bar-demo
    $ edit AndroidManifest.xml
    $ edit src/com/example/actionbardemo/ActionBarDemo.java
    $ android update project -p . -l ../appcompat

Compile and install.

    $ ant debug install

Then run the app on device, it *works*.




# Using Sbt

Next, I create `Build.scala` and `plugins.sbt` in directory `project`.


## `plugins.sbt`

```
addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.2.3")
```


## `Build.scala`

I borrowed `Build.scala` from the plugin's [wiki].


BTW, it seems the wiki page is outdated:

1. `import AndroidKeys._` should be `import android.Keys._`.
2. `AndroidSdkPlugin.androidBuildSettings` should be 
`android.Plugin.androidBuild`.


Finally, the content of `project/Build.scala` is:

```
import sbt._
import sbt.Keys._

import android.Keys._

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, appcompat)


  // android application project
  lazy val myproject = Project(id = "myproject", base = 
file("action-bar-demo")) settings(
    appSettings:_*
  )

  val appcompat = Project(id = "appcompat",
    base = file("appcompat")) settings(
    android.Plugin.androidBuild: _*)

  lazy val appSettings = android.Plugin.androidBuild :+
  (name := "actionbardemo") :+
  (compile in Compile <<= compile in Compile
    dependsOn(packageT in Compile in appcompat))
}
```

Run the app on device, the ActionBar cannot be displayed properly.

    $ sbt myproject/android:run


Is there any problem in my `Build.scala`?  Please help me.  Thank you.




[android-sdk-plugin]: https://github.com/pfn/android-sdk-plugin
[wiki]: 
https://github.com/pfn/android-sdk-plugin/wiki/Working-with-Android-library-projects




Best Regards,
Des

-- 
You received this message because you are subscribed to the Google Groups 
"scala-on-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to