Hudson Android Emulator Pluginを使ってみる
前回の記事でHudsonからEmulatorを起動できない件の続きです。
vvakameさんとandroidzaurusさん、bols-blueさんからいろいろ助言をいただきました。ありがとうございます。
結果報告
Emulatorが起動するまで待つっていうコマンドを教えてもらったので早速実行
コマンド
adb wait-for-device
で実行コマンドを以下のように変更
adb wait-for-device shell am instrument -w com.example.hellohudson.tests/android.test.InstrumentationTestRunner
結果はNGでした。
log
+ adb wait-for-device shell am instrument -w com.example.hellohudson.tests/android.test.InstrumentationTestRunner Error type 2 Error: Unable to connect to activity manager; is the system running? usage: am [start|broadcast|instrument|profile] am start [-D] INTENT am broadcast INTENT am instrument [-r] [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>] [-w] <COMPONENT> am profile <PROCESS> [start <PROF_FILE>|stop] INTENT is described with: [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-c <CATEGORY> [-c <CATEGORY>] ...] [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...] [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...] [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...] [-n <COMPONENT>] [-f <FLAGS>] [<URI>] Finished: SUCCESS
見かけ上成功してますが、しっかりError吐いてます。
で、 Android Emulator Plugin があるのでそれを使いました。
http://wiki.hudson-ci.org/display/HUDSON/Android+Emulator+Plugin
→失敗
手順
Android Emulator Plugin のインストール
Android Emulator Plugin の設定
- Hudsonの管理メニューを開く
- "システムの設定"メニューを開く
- "Android Emulator"の欄が追加されているので、"Android SDK root"にandroid-sdkのパスを入力する
- 画面一番下の"保存"ボタンをクリック
- 前回作成したジョブ"HelloHudsonTest"を選択
- "設定"メニューを開く
- ビルド環境に"Run an Android emulator during build"が追加されているのでチェックする
- "Run existing emulator"にチェックを入れる
- AVD nameに作成したEmulator名を記入
- "Common emulator options"の設定
- "Reset emulator state at start-up":チェック(画像にはチェックがないけど実際はチェック。てゆーか、チェックとかいらないかも)
- "Show emulator window":チェック
- "シェルの実行"のコマンド
- logcatクリアコマンド追加
logcat -c ant adb shell am instrument -w com.example.hellohudson.tests/android.test.InstrumentationTestRunner
- 画面下の"保存"をクリック
テストする
ビルドを実行すると自動的にエミュレータが起動します。
- "ビルドの実行"をクリック
- 左下の"ビルド履歴"から実行中のビルド番号を選択>"コンソール出力"を選択
- 完了するまでログをながめる
- 成功したことを確認する
log
〜略〜 [android] Emulator is ready for use (took 94 seconds) [workspace] $ /bin/sh -xe /tmp/hudson1986880721112408258.sh + adb logcat -c + ant Buildfile: build.xml [setup] Android SDK Tools Revision 7 [setup] Project Target: Android 1.6 [setup] API level: 4 [setup] [setup] ------------------ [setup] Resolving library dependencies: [setup] ------------------ [setup] Ordered libraries: [setup] ------------------ [setup] [setup] WARNING: No minSdkVersion value set. Application will install on all Android versions. [setup] [setup] Importing rules file: tools/ant/ant_test_rules_r3.xml help: [echo] Android Ant Build. Available targets: [echo] help: Displays this help. [echo] clean: Removes output files created by other targets. [echo] compile: Compiles project's .java files into .class files. [echo] debug: Builds the application and signs it with a debug key. [echo] release: Builds the application. The generated apk file must be [echo] signed before it is published. [echo] install: Installs/reinstalls the debug package onto a running [echo] emulator or device. [echo] If the application was previously installed, the [echo] signatures must match. [echo] uninstall: Uninstalls the application from a running emulator or [echo] device. BUILD SUCCESSFUL Total time: 0 seconds + adb shell am instrument -w com.example.hellohudson.tests/android.test.InstrumentationTestRunner INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.example.hellohudson.tests/android.test.InstrumentationTestRunner} INSTRUMENTATION_STATUS: id=ActivityManagerService INSTRUMENTATION_STATUS_CODE: -1 INSTRUMENTATION_FAILED: com.example.hellohudson.tests/android.test.InstrumentationTestRunner usage: am [start|broadcast|instrument|profile] am start [-D] INTENT am broadcast INTENT am instrument [-r] [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>] [-w] <COMPONENT> am profile <PROCESS> [start <PROF_FILE>|stop] INTENT is described with: [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-c <CATEGORY> [-c <CATEGORY>] ...] [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...] [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...] [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...] [-n <COMPONENT>] [-f <FLAGS>] [<URI>] $ /home/ore/develop/android/android-sdk-linux_x86/tools/adb disconnect localhost:40870 [android] Stopping Android emulator [android] Archiving emulator log Finished: SUCCESS 更新: 2010/09/24 21:07:20Hudson ver. 1.377
成功しているように見えるけど、
INSTRUMENTATION_FAILED: com.example.hellohudson.tests/android.test.InstrumentationTestRunner
って出てる・・・orz
成果物の確認
成果物にlogcat.txtができてることを確認する
- "状態"を選択
- ビルドの成果物に"logacat.txt"がいることを確認
ログから考えるとたぶんapkがないだけの様子。
つまり
adb install XX.apk
を実行すればよさげ。
で実行コマンドに追加
adb install HelloHudsonTest.apk
結果
apkが見つからないと怒られる。
今日はここまで。
Hudsonでエミュレータが起動できない問題はまだ解決できてませんが、だいぶ近づいてきたと思います。