iRSSの日記

はてなダイアリーiRSSの日記の続き

MacOSXで動く開発環境をちゃんと作る

先月から、Android開発のために、Javaでプログラミングしています。
当然開発環境はEclipseなんだけど、適当に入れたら重くなったり、ライブラリパスが壊れたりといろいろ問題発生。
なので、もう一度最初からやり直してみます。

直る保証は無いけれど、うまくいといいなあ

エクリプスのダウンロード

A Java or RCP version of Eclipse is recommended. For Eclipse 3.5, the "Eclipse Classic" version is recommended.

バージョンを間違えないようにしましょう。

eclipseは解凍後フォルダごと、/Developer/ に移動。ここは、別の場所でもいいです。

/Developer/eclipse

SDKをダウンロード

Mac OS X (intel) android-sdk_r04-mac_86.zip 19657927 bytes b08512765aa9b0369bb9b8fecdf763e3

こちらも解凍後、/Developer/ に移動。あとでeclipseから、SDKの場所を設定する。

/Developer/android-sdk-mac_86

SDKにはコマンドラインから起動できるツールがあるので、パスを通します。

On a Mac OS X, look in your home directory for .bash_profile and proceed as for Linux. You can create the .bash_profile if you haven't already set one up on your machine.

$ vim ~/ .bash_profile

で以下のように編集

if [ -f ~/.bashrc ] ; then
    . ~/.bashrc
fi
ANDROID_HOME=/Developer/android-sdk-mac_86
PATH=$PATH:${ANDROID_HOME}/tools

↑ここですが、.bash_profileはどうも、shell起動時に、読まれないらしい。
.bashrcに書いたほうが良さげ。

$ vim ~/ .bashrc


最後に以下2行を追加すれば大丈夫だった。

ANDROID_HOME=/Developer/android-sdk-mac_86
PATH=$PATH:${ANDROID_HOME}/tools

eclipse起動しSDKの設定を行う。

1.Helpメニュー > Install New Softare.
2.Addボタンを押してurlの追加
あとは、以下のように順次。





Start Eclipse, then select Help > Install New Softare.
In the Available Software dialog, click Add....
In the Add Site dialog that appears, enter a name for the remote site (for example, "Android Plugin") in the "Name" field.
In the "Location" field, enter this URL:
https://dl-ssl.google.com/android/eclipse/
Note: If you have trouble aqcuiring the plugin, you can try using "http" in the URL, instead of "https" (https is preferred for security reasons).
Click OK.
Back in the Available Software view, you should now see "Developer Tools" added to the list. Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next.
In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish.
Restart Eclipse.

この手順通りにだいたい、迷わずいけるかと思います。

eclipse再起動後、SDKの設定を行う。

Select Window > Preferences... to open the Preferences panel (Mac OS X: Eclipse > Preferences).
Select Android from the left panel.
For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory.
Click Apply, then OK.

/Developer/android-sdk-mac_86

を選びました。

Adding SDK Components

まだまだ、つづきます

ターミナルで

$ android

として「SDK and AVD Manager 」を起動。


↑必要なSDKだけにしておいてOK、ひとまずは1.5と1.6かな。


httpsが使えないといわれたら、settingでForce https://...souces to be fetched using http://...を使えばOK

さらに、X10のエニュレータが必要ならSony Ericsson XPERIA™ X10のSDKをダウンロードしてみた - iRSSの日記を参考にインストール。

これで、一通りインストールは完了したが、エミュレーターのイメージが必要なので、次はその作成

エミュレーターの作成

Android SDK and AVD Managerを起動し、Newボタンを押して、NameとTargetを指定する。
Nameは任意の名前でOKだけど、OSのバージョンとかを名前に入れておくと起動時にわかりやすい。

エミュレーターの起動

Startボタンを押せば、起動します!

こちらはX10の例。
起動には、1分くらいかかりますが、これはしょうがないので、気長に待ちましょう。

HelloWorldができたら、その次はApiDemoを

http://developer.android.com/intl/ja/resources/samples/ApiDemos/index.html
こちらにもありますが、なにができるか、だいたいつかめるので、これはぜひ、みてみましょう。
Eclipse > File > New > Project >AndroidProject
でCreate Project from Existing Sampleのプルダウンから選ぶ事ができます。