Scala で Android
ここ見て実践
今度はScalaでHelloAndroid - papamitra
Eclipse 使いたくない人としては願ってもない内容なので、がんばってみる
プロジェクト作成
android create project --target $version --path $dir --activity ClassName --package $packagename
--taget は android list targets で出てくるものの id を指定すれば ok
ここでは 2.1 用に作るので、 6 を指定した。
scala 環境
The Scala Programming Language から実行環境を落としてきて、 sbaz scala-android でインストール。 ./lib に scala-android.jar がダウンロードされる。
apt-get install proguard
で proguard を入れておく
build.xml 書き換え
http://github.com/phueper/AndroidScalaAntTest/raw/master/android_rules.xml
をダウンロードしておき、適当なところに置く
で、build.xml を書き換える
<!-- Execute the Android Setup task that will setup some properties specific to the target, and import the build rules files. The rules file is imported from <SDK>/platforms/<target_platform>/templates/android_rules.xml To customize some build steps for your project: - copy the content of the main node <project> from android_rules.xml - paste it in this build.xml below the <setup /> task. - disable the import by changing the setup task below to <setup import="false" /> This will ensure that the properties are setup correctly but that your customized build steps are used. --> <setup import="false" /> <import file="/path/to/android_rules.xml" />
その後、 android_rules.xml も書き換える。
sdk-location が存在しなかったので定義
<property name="sdk-location" value="/path/to/android-sdk-linux_86" />
scala.home やら android 用のパスやらを書き換える。
android-jar は存在しなかったので付け足し。
<property name="scala.home" value="/path/to/scala-2.7.7.final" /> <property name="scala-android.jar" value="${scala.home}/lib/scala-android.jar" /> <property name="scala-library.jar" value="${scala.home}/lib/scala-library.jar" /> <property name="sdk-folder" value="${sdk-location}/platforms/android-7" /> <property name="android-tools" value="${sdk-folder}/tools" /> <property name="apk-builder" value="${sdk-location}/tools/apkbuilder" /> <property name="adb" value="${sdk-location}/tools/adb" /> <property name="android-jar" value="${sdk-folder}/android.jar" />
実行
ant install で動いた!