サンプルの実行
Androidのサンプルを作って実行してみる。
参照元は、http://developer.android.com/intl/ja/resources/tutorials/hello-world.html
Android本家のチュートリアルだ。
新規でAndroidプロジェクトを作成すると、プロジェクトに赤いエラーマークがついている。
内容を見てみると、/genが見あたらないと言っているようだ。
で、ググってみると一度ビルドをすると自動生成されるディレクトリらしいのでビルドを実施するとエラーが消えた。
で、エミュレータを起動すると、下のようなエラー(emulator-5554 disconnected!)が発生して
目的の画面ではなく、デモ画面のような画面になってしまう。
[2010-06-16 14:40:11 - HellowWorld] ------------------------------ [2010-06-16 14:40:11 - HellowWorld] Android Launch! [2010-06-16 14:40:11 - HellowWorld] adb is running normally. [2010-06-16 14:40:11 - HellowWorld] Performing net.hellowworld.HellowWorld activity launch [2010-06-16 14:40:11 - HellowWorld] Automatic Target Mode: launching new emulator with compatible AVD 'testDev01' [2010-06-16 14:40:11 - HellowWorld] Launching a new emulator with Virtual Device 'testDev01' [2010-06-16 14:40:26 - HellowWorld] New emulator found: emulator-5554 [2010-06-16 14:40:26 - HellowWorld] Waiting for HOME ('android.process.acore') to be launched... [2010-06-16 14:41:50 - HellowWorld] emulator-5554 disconnected! Cancelling 'net.hellowworld.HellowWorld activity launch'!
ググってみて、メモリが足りてないのかもと思い、エミュレータのSD RAMサイズを64Mbyteにして、
あと、デバッグ環境の設定で、Launch Default Activityを止めて、起動でサンプルコードを指定するように修正。
[2010-06-16 14:42:12 - HellowWorld] ------------------------------ [2010-06-16 14:42:12 - HellowWorld] Android Launch! [2010-06-16 14:42:12 - HellowWorld] adb is running normally. [2010-06-16 14:42:12 - HellowWorld] Performing net.hellowworld.HellowWorld activity launch [2010-06-16 14:42:12 - HellowWorld] Automatic Target Mode: Preferred AVD 'testDev02' is not available. Launching new emulator. [2010-06-16 14:42:12 - HellowWorld] Launching a new emulator with Virtual Device 'testDev02' [2010-06-16 14:42:24 - HellowWorld] New emulator found: emulator-5554 [2010-06-16 14:42:24 - HellowWorld] Waiting for HOME ('android.process.acore') to be launched... [2010-06-16 14:46:32 - HellowWorld] HOME is up on device 'emulator-5554' [2010-06-16 14:46:32 - HellowWorld] Uploading HellowWorld.apk onto device 'emulator-5554' [2010-06-16 14:46:32 - HellowWorld] Installing HellowWorld.apk... [2010-06-16 14:47:03 - HellowWorld] 成功! [2010-06-16 14:47:04 - HellowWorld] Starting activity net.hellowworld.HellowWorld on device [2010-06-16 14:47:14 - HellowWorld] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=net.hellowworld/.HellowWorld } [2010-06-16 14:47:18 - HellowWorld] Attempting to connect debugger to 'net.hellowworld' on port 8601
これで目標の"Hello World"が表示できた。でも、起動までにかなり時間が掛かるのはどうして?