scalaでandroid開発しようとしてくじけそうになったのでメモ

2011-06-13

scalaでandroid開発しようとしてくじけそうになったのでメモ

scalaでandroidの開発が出来るそうなので、やってみようとしたらくじけそうになったので、他の人がくじけないようにメモ。  

1. 基本的なインストラクション

【import jp.武田ソフト.ブログ._】さんのエントリーを参考にしました。 sbtを使って、android-scala-pluginを導入します。  

2. sbt updateが出来ぬ・・・

ANDROID_SDKインストールして、sbtのプロジェクト作るとこまではスムーズ。だけど、作ったプロジェクトでsbt updateすると、必ず以下のエラーが・・・。

1
2
3
4
5
6
7
8
9
[warn]          ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-tools.sbt#sbt-android-plugin;0.5.2-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[info]
[info] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
[error] sbt.ResolveException: unresolved dependency: org.scala-tools.sbt#sbt-android-plugin;0.5.2-SNAPSHOT: not found
sbt.ResolveException: unresolved dependency: org.scala-tools.sbt#sbt-android-plugin;0.5.2-SNAPSHOT: not found

  sbtの仕組みがいまいち分かってないので、何とも言えないけど、依存関係のあるパッケージ(一番大事なやつ)が取ってこれてないらしい・・・。  

3. ライブラリを自分でコンパイル

しょうがないので、sbt-android-pluginをgithubから取ってきて自分でコンパイルしてみる。 githubのURLは、こちら→https://github.com/jberkel/android-plugin 上手く行くと、$HOME/.ivy2の下にjarが出来てる。

1
2
3
4
5
6
7
8
9
10
git clone https://github.com/jberkel/android-plugin.git
cd android-plugin
sbt update
sbt publish-local
find ~/.ivy2/ -name "*0.5.2*"
/home/hoge/.ivy2/cache/org.scala-tools.sbt/sbt-android-plugin/ivydata-0.5.2-SNAPSHOT.properties
/home/hoge/.ivy2/cache/org.scala-tools.sbt/sbt-android-plugin/ivy-0.5.2-SNAPSHOT.xml
/home/hoge/.ivy2/cache/resolved-org.scala-tools.sbt-sbt-android-plugin-0.5.2-SNAPSHOT.xml
/home/hoge/.ivy2/cache/resolved-org.scala-tools.sbt-sbt-android-plugin-0.5.2-SNAPSHOT.properties
/home/hoge/.ivy2/local/org.scala-tools.sbt/sbt-android-plugin/0.5.2-SNAPSHOT

  まあ、2011/6/12現在の話なので、時が立てばこんなことしなくてもよくなると思われる。  

4. 再チャレンジ

sbt-android-plugin-0.5.2-SNAPSHOT.jarは、sbt? maven?のローカルキャッシュディレクトリにpublishされているので、あとは普通にsbt updateすればOKになる。

1
2
3
4
5
6
7
8
9
cd HelloProject
sbt update
----------------------中略---------------------------
[success] Successful.
[info]
[info] Total time: 1 s, completed 2011/06/12 6:33:08
[info]
[info] Total session time: 33 s, completed 2011/06/12 6:33:08
[success] Build completed successfully.

大成功。 って、まだ肝心のアプリにまで到達してない・・・(-o-;)  

5. HelloWorld

後は、sbtでコマンド叩けば、HelloWorld出来る。

1
2
3
sbt
>compile
>install-device

※emulator使っている人は、install-emulator。   ちなみに、sbt-android-pluginには、screenshot-device, screenshot-emulatorという便利コマンドがあって、画面キャプチャが簡単に撮れる。証拠品は以下。 [caption id=”attachment_1549” align=”aligncenter” width=”180” caption=”HelloWorld!”]HelloWorld[/caption]   ひとまず、sbt使って、scala-android開発の序章は終わった感じ。 以後、実際の開発へ向かう・・・。