Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

解決 Android 模擬器 Failed to create Context 0x3005 與 OpenGL ES 模擬初始化失敗

編輯:關於 Android 程式設計

把 Eclipse、SDK 與 ADT 都更新到最新版之後,家裡的環境一切正常;換到公司機器上執行模擬器卻直接失敗。錯誤訊息大致如下:

Failed to create Context 0x3005
emulator: WARNING: Could not initialize OpenglES emulation, using software renderer...

這個問題在換機器、換使用者環境或更新 SDK 之後特別容易出現,嘗試重開模擬器、刪除 AVD 重建通常都沒有用。

社群中流傳的解法

在 Google Code 的論壇上可以找到一段相當有代表性的排查紀錄:

Make sure your graphics card driver is up to date.
  1. Installed the Android Bundle.
  2. Created an AVD.
  3. Clicked the start button and the emulator does not open.
  4. No error messages are reported as the "Starting Android Emulator" dialogue times out.
We tried running emulator.exe from the command line (emulator -avd <name>) and noticed that OpenGL was erroring out. But interestingly emulator-x86 -avd <name> would actually work and fire up the emulator.
We then tried moving the four DLLs from the /tools/lib directory to the /tools directory. Even more interestingly, after we did that emulator-x86 stopped working and began pitching a fit about the OpenGL ES.
So we downloaded the newest graphics driver, left the DLLs in the /tools directory, and finally the emulator would fire up from Eclipse as well as from the command line.

這段描述裡有幾個值得注意的線索:命令行執行 emulator -avd 時會看到 OpenGL 相關錯誤;改用 emulator-x86 -avd 反而能啟動;而搬動 tools/lib 下的 DLL 會讓情況變得更糟。種種現象都指向同一個方向——圖形驅動的問題,而不是模擬器本身的問題。

根本原因與解法

關鍵就在 newest graphics driver 這句話。裝一個驅動檢測工具掃一下,就會發現顯卡驅動可能停留在好幾年前的版本(例如 2008 年版)。把它升級到最新版、重新開機,模擬器就能正常啟動了。

所以遇到 Failed to create Context 0x3005 時,建議的排查順序是:

  1. 更新顯卡驅動。這是最有效的一招,多數案例都是這個原因。
  2. 檢查 GPU 模擬設定:在 AVD 設定中,把 Sun Graphics Device 相關選項在「Host GPU」與「Software」之間切換試試。若實體顯卡支援不足,改用軟體渲染能繞過問題。
  3. 不要隨便搬動 DLL:tools/lib 下的檔案有其載入路徑依賴,手動搬移只會製造新的錯誤。
  4. 確認啟動腳本:直接從命令列執行並觀察完整輸出,比只看 Eclipse 的簡短提示更能定位問題。

現代 Android Studio 的模擬器(QEME 引擎)在這方面的處理已改善不少,若在舊版 SDK 上遇到此問題且驅動更新無效,考慮改用實體裝置除錯往往比繼續折騰模擬器更省時間。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved