在學習使用Flutter做Android開發的時候,涉及到演示,這裏爲了方便,使用藍蝶模擬器做安卓虛擬機,在flutter run 的時候遇到了如下問題
D:\test\Android\flutter_app>flutter run -d all
Launching lib/main.dart on GT I9500 in debug mode...
Initializing gradle... 1.6s
Resolving dependencies... 7.4s
Gradle task 'assembleDebug'...
Gradle task 'assembleDebug'... Done 12.2s
Built build\app\outputs\apk\debug\app-debug.apk.
E/flutter ( 6146): [ERROR:flutter/shell/platform/android/android_context_gl.cc(165)] Could not choose an EGL configuration.
E/flutter ( 6146): [ERROR:flutter/shell/platform/android/android_context_gl.cc(53)] EGL Error: EGL_SUCCESS (12288)
F/flutter ( 6146): [FATAL:flutter/shell/platform/android/platform_view_android.cc(28)] Check failed: android_surface_. Could not create an OpenGL, Vulkan or Software surface to setup rendering.
E/flutter ( 6173): [ERROR:flutter/shell/platform/android/android_context_gl.cc(165)] Could not choose an EGL configuration.
E/flutter ( 6173): [ERROR:flutter/shell/platform/android/android_context_gl.cc(53)] EGL Error: EGL_SUCCESS (12288)
F/flutter ( 6173): [FATAL:flutter/shell/platform/android/platform_view_android.cc(28)] Check failed: android_surface_. Could not create an OpenGL, Vulkan or Software surface to setup rendering.
E/flutter ( 6207): [ERROR:flutter/shell/platform/android/android_context_gl.cc(165)] Could not choose an EGL configuration.
E/flutter ( 6207): [ERROR:flutter/shell/platform/android/android_context_gl.cc(53)] EGL Error: EGL_SUCCESS (12288)
F/flutter ( 6207): [FATAL:flutter/shell/platform/android/platform_view_android.cc(28)] Check failed: android_surface_. Could not create an OpenGL, Vulkan or Software surface to setup rendering.
E/flutter ( 6229): [ERROR:flutter/shell/platform/android/android_context_gl.cc(165)] Could not choose an EGL configuration.
E/flutter ( 6229): [ERROR:flutter/shell/platform/android/android_context_gl.cc(53)] EGL Error: EGL_SUCCESS (12288)
F/flutter ( 6229): [FATAL:flutter/shell/platform/android/platform_view_android.cc(28)] Check failed: android_surface_. Could not create an OpenGL, Vulkan or Software surface to setup rendering.
後來翻牆,在GitHub上總算找到解決辦法,忽略配置
//使用以下命令代替flutter run
flutter run --enable-software-rendering -d all
詳細GitHub原問題見:https://github.com/flutter/flutter/issues/22671
(注意要翻牆!!!)
成功如下: