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/com.dom925.volcamr.nz E/EGL_emulation: rcCreateContext returned 0
08-07 00:50:44.429 3266-3523/com.dom925.volcamr.nz E/EGL_emulation: tid 3523: eglCreateContext(1434): error 0x3003 (EGL_BAD_ALLOC)
                                                                    
                                                                    --------- beginning of crash
08-07 00:50:44.429 3266-3523/com.dom925.volcamr.nz E/AndroidRuntime: FATAL EXCEPTION: GLThread 276
                                                                     Process: com.dom925.volcamr.nz, PID: 3266
                                                                     java.lang.RuntimeException: createContext failed: 12291
                                                                         at com.google.maps.api.android.lib6.gmm6.vector.az.a(:com.google.android.gms.DynamiteModulesB:29)
                                                                         at com.google.maps.api.android.lib6.gmm6.vector.ba.f(:com.google.android.gms.DynamiteModulesB:158)
                                                                         at com.google.maps.api.android.lib6.gmm6.vector.ba.run(:com.google.android.gms.DynamiteModulesB:11)

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.