Monday, August 7, 2017

Android Studio Emulator: How I resolved a Google Maps SupportMapFragment GLThread exception

While attempting to open up a Google Maps SupportMapFragment in the Android Studio Emulator, the Activity crashed with the following error messages:

[ 08-07 00:50:44.423  3266: 3523 W/         ]
                                                                     Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 
08-07 00:50:44.429 3266-3523/ E/EGL_emulation: rcCreateContext returned 0
08-07 00:50:44.429 3266-3523/ E/EGL_emulation: tid 3523: eglCreateContext(1434): error 0x3003 (EGL_BAD_ALLOC)
                                                                    --------- beginning of crash
08-07 00:50:44.429 3266-3523/ E/AndroidRuntime: FATAL EXCEPTION: GLThread 276
                                                                     Process:, PID: 3266
                                                                     java.lang.RuntimeException: createContext failed: 12291

The same Android app has no issue running on a real handset.

After some fiddling around with the emulator settings, the problem was resolved by changing the emulator's graphics emulated performance from automatic to either Hardware GLES 2.0 or Software GLES 2.0 as shown below.