知人から Android の開発環境なら Titanium って言うのが有るよ、 と教えてもらったのでちょっと調べてみた。

Titanium は HTML+JavaScript で記述したソースを Android と iPhone の両方のバイナリにコンパイルする事ができる結構凄いやつらしい。

この辺を参考に開発環境を作ってみた。

  • http://www.atmarkit.co.jp/fsmart/articles/titanium01/01.html
  • http://code.google.com/p/titanium-mobile-doc-ja/
  • http://developer.appcelerator.com/
  • http://wiki.appcelerator.org/display/guides/Getting+Started+with+Titanium
Titanium はバイナリ形式でしか供給されていないので FreeBSD でやるのは最初からあきらめて VirtualBox 上の WinXP でやることにした。

とりあえず Win32 版を落してインストールすると問題なくインストールできた。

最初にユーザ登録が必要。

メールアドレスとパスワード、姓、名だけ入力すれは良い。
※VirtualBoxのNICの設定がNATだとうまく行かなかった。Bridgeにしたらうまく行った。

次に Android の開発環境をインストールする。

  • http://developer.android.com/sdk/index.html
インストールしたディレクトリをTitaniumに設定する。

ここで問題発生。

adb.exe が見付からないと言っている。
adb.exe は最近のバージョンで tools/ から platform-tool/ に 移動されているので1つ前のバージョンに戻したが 今度は package の update ができない。

いろいろ悩んだあげく GettingStart を良く読んだら書いてあった。

Titanium Developer expects the adb executable to be in the same location, 
ie $ANDROID_SDK/tools, as the Android SDK and AVD Manager (android executable),
but Google has recently moved it to $ANDROID_SDK/platform-tools. 
Thus, it is necessary to create a symbolic link in $ANDROID_SDK/tools 
that references the new location.

For Linux, create the symbolic link as follows:
For Windows, you must create a symbolic link for adb.exe and its associated AdbWinApi.dll:

adb.exe と DLL を tools/ にコピーしたらあっさり解決。
これ Titanium 側をちょこっと直せば済む話しなんじゃねーの?
絶対はまるだろ。

サンプルプログラムをインポートして実行するも途中でエラーになり失敗する。


根が深そうなので一旦、諦め新規作成したプロジェクトを実行してみる。

  • ProjectType を Mobile にする。
  • AppId はドットを含むパッケージ名になっていないとコンパイル時におかしくなる。 参考:http://d.hatena.ne.jp/siso9to/20110404/1301933484
  • Name,Dir,URLは適当に。
実行してみる。

Android のバージョンを選んで Launch をクリックするとエミュレータが立ち上がって インストールまでやってくれる。

おぉ一応、初期画面が出て来た。

タブを2つ出している初期状態のプログラムはこうなっていた。 // this sets the background color of the master UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#000'); // create tab group var tabGroup = Titanium.UI.createTabGroup(); // // create base UI tab and root window // var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var tab1 = Titanium.UI.createTab({ icon:'KS_nav_views.png', title:'Tab 1', window:win1 }); var label1 = .createLabel({ color:'#999', text:'I am Window 1', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win1.add(label1); // // create controls tab and root window // var win2 = Titanium.UI.createWindow({ title:'Tab 2', backgroundColor:'#fff' }); var tab2 = Titanium.UI.createTab({ icon:'KS_nav_ui.png', title:'Tab 2', window:win2 }); var label2 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 2', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win2.add(label2); // // add tabs // tabGroup.addTab(tab1); tabGroup.addTab(tab2); // open tab group tabGroup.open();

Titanium.UI の API を理解すればそれなりにアプリが作れそうな 感じではある。
但し、この環境ではソース修正からエミュレータに画面が現れるまで 1分くらいかかってしまうので実際の開発に使うのはかなり厳しそう。