2012年8月18日土曜日

pfn/android-sdk-pluginでAndroidのScala開発環境を構築(2)

pfn/android-sdk-pluginでAndroidのScala開発環境を構築(2) Android, Eclipse, Scala, Ubuntu,

概要は pfn/android-sdk-pluginでAndroidのScala開発環境を構築 を参照。

プロジェクトの作成

$ android create project --target android-16 --path ./chokinbo --package net.itsuha.chokinbo --activity MainActivity

pfn/android-sdk-plugin の設定

$ mkdir project
$ cat << END > project/plugin.sbt
resolvers += Resolver.url("scala-sbt releases", new URL(
    "http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(
    Resolver.ivyStylePatterns)

addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "0.3.6")
END
$ cat << END > project/build.properties
sbt.version=0.11.2
END
$ cat << END > build.sbt
name := "Chokinbo"

seq(androidBuildSettings: _*)
END

build.sbtはprojectディレクトリではなく、プロジェクトルート直下なので注意。

Javaソースのみでsbtを実行し、実機にインストールできることを確認

$ sbt
> android:run

Scalaソースの追加、実行

$ rm src/net/itsuha/chokinbo/MainActivity.java
$ cat << END > src/net/itsuha/chokinbo/MainActivity.scala
package net.itsuha.chokinbo

import _root_.android.app.Activity
import _root_.android.os.Bundle

class MainActivity extends Activity {
  override def onCreate(bundle: Bundle) {
    super.onCreate(bundle)
    setContentView(R.layout.main)
  }
}
END

$ sbt
> android:run

Javaの場合と異なり、自動でProguardが実行される。

1 件のコメント:

  1. Think the Eagles will proceed to dominate, but not end up profitable it all? Buy them now, watch their value rise or fall, after which commerce out whenever you need. Earn 30% of the SPORTS token betting charges paid by your Referrals for the first 6 months. After day 15, ZenSports will mechanically credit your SPORTS token wallet in ZenSports with this Welcome Bonus -- no want so that you can} take any further motion or do something at all. 토토사이트 That quantity will solely increase when the MLB playoffs, NBA and NHL seasons get underway later this month into October. Community Rules apply to all content you upload or in any other case submit to this website.

    返信削除