2016-09-27 284 views
0

我有一臺運行Jenkins CI 2.7.4的Mac Mini服務器,並且已經創建了一個工作來構建我的Android項目。該工作還通過Android模擬器插件運行模擬器以運行一些Espresso測試。但是,我遇到了模擬器從未真正啓動的問題。我選中了「顯示模擬器窗口」選項。Jenkins CI - Android模擬器無法啓動

下面是輸出:

[android] Using Android SDK: /Users/Shared/Jenkins/Home/tools/android-sdk 
[android] Adding 128M SD card to AVD 'hudson_en-US_120_WXGA720_android-23_x86'... 
$ /Users/Shared/Jenkins/Home/tools/android-sdk/platform-tools/adb start-server 
* daemon not running. starting it now on port 5832 * 
* daemon started successfully * 
$ /Users/Shared/Jenkins/Home/tools/android-sdk/platform-tools/adb start-server 
$ /Users/Shared/Jenkins/Home/tools/android-sdk/tools/emulator -snapshot-list -no-window -avd hudson_en-US_120_WXGA720_android-23_x86 
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL. 
WARNING: Force to use classic engine to support snapshot. 
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL. 
[android] Starting Android emulator and creating initial snapshot 
[android] Erasing existing emulator data... 
$ /Users/Shared/Jenkins/Home/tools/android-sdk/tools/emulator -engine classic -ports 5730,5731 -report-console tcp:5852,max=60 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_120_WXGA720_android-23_x86 -no-snapshot-load -no-snapshot-save -wipe-data 
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL. 
WARNING: Force to use classic engine to support snapshot. 
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL. 
2016-09-27 14:31:02.344 emulator64-x86[981:7440] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data 
PasteBoard: Error creating pasteboard: com.apple.pasteboard.clipboard [-4960] 
2016-09-27 14:31:02.344 emulator64-x86[981:7440] CFPasteboardRef CFPasteboardCreate(CFAllocatorRef, CFStringRef) : failed to create global data 
PasteBoard: Error creating pasteboard: com.apple.pasteboard.find [-4960] 
no screens available, assuming 24-bit color 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextSetFillColorWithColor: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextFillRects: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
QPaintDevice::metrics: Device has no metric information 
QPaintDevice::metrics: Device has no metric information 
QPaintDevice::metrics: Device has no metric information 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetDefaultUserSpaceToDeviceSpaceTransform: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetDefaultUserSpaceToDeviceSpaceTransform: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetDefaultUserSpaceToDeviceSpaceTransform: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetDefaultUserSpaceToDeviceSpaceTransform: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetDefaultUserSpaceToDeviceSpaceTransform: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetDefaultUserSpaceToDeviceSpaceTransform: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetDefaultUserSpaceToDeviceSpaceTransform: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextConcatCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextGetDefaultUserSpaceToDeviceSpaceTransform: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Sep 27 14:31:02 emulator64-x86[981] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable. 
Cannot create window: no screens available 
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored. 
[android] Emulator did not appear to start; giving up 
[android] Stopping Android emulator 
$ /Users/Shared/Jenkins/Home/tools/android-sdk/platform-tools/adb kill-server 
Finished: NOT_BUILT 

我得到一個超時錯誤,如果我選中 「顯示仿真器窗口」:

$ /Users/Shared/Jenkins/Home/tools/android-sdk/platform-tools/adb -s emulator-5752 wait-for-device shell getprop init.svc.bootanim 
[android] Emulator reported that the startup process is 'running' 
$ /Users/Shared/Jenkins/Home/tools/android-sdk/platform-tools/adb -s emulator-5752 wait-for-device shell getprop init.svc.bootanim 
[android] Emulator reported that the startup process is 'running' 
$ /Users/Shared/Jenkins/Home/tools/android-sdk/platform-tools/adb -s emulator-5752 wait-for-device shell getprop init.svc.bootanim 
[android] Emulator reported that the startup process is 'running' 
$ /Users/Shared/Jenkins/Home/tools/android-sdk/platform-tools/adb -s emulator-5752 wait-for-device shell getprop init.svc.bootanim 
[android] Emulator reported that the startup process is 'running' 
$ /Users/Shared/Jenkins/Home/tools/android-sdk/platform-tools/adb -s emulator-5752 wait-for-device shell getprop init.svc.bootanim 
[android] Emulator reported that the startup process is 'running' 
[android] Timed-out after waiting 360 seconds for emulator 
[android] Stopping Android emulator 
$ /Users/Shared/Jenkins/Home/tools/android-sdk/platform-tools/adb kill-server 
Finished: NOT_BUILT 
+0

貌似你試圖運行模擬器無頭,即不是在登錄界面會?它沒有「顯示模擬器窗口」工作嗎? –

回答

1

嘗試增加超時。我有類似的情況,直到我這樣做纔得到解決。

com.android.ddmlib.DdmPreferences.setTimeOut(600000) 
android { 
} 

並添加環境屬性ADB_INSTALL_TIMEOUT = 5

+1

這似乎並沒有爲我工作。我試圖複製命令並在終端窗口中運行它,但仍然沒有運氣。 Android模擬器加載窗口彈出,但最終超時。但是,如果我從命令中刪除「-report-console tcp:5855,max = 60」,那麼我可以讓它在終端中運行。有沒有辦法覆蓋Android模擬器插件的整體命令和參數? – Zac

+0

'-report-console'在終端上沒有用處,但是它在插件內部工作(否則你不會像「Emulator報告啓動過程'正在運行'一樣」)。 您可以添加其他參數(在「高級」下),但可以從插件使用的命令行中刪除現有的參數。 –

+0

@ChristopherOrr,只需卸載並重新安裝Jenkins CI,我就能夠使其處於工作狀態。它仍然顯示'_RegisterApplication(),FAILED TO建立到WindowServer錯誤的默認連接,但只要我不選中「顯示模擬器窗口」選項,那麼它將成功構建並運行我的Espresso作業。 – Zac