# Trying to run sample AndEngine gles2 code in the simulator throws “java.lang.IllegalArgumentException: No EGLConfig found!”, how can I fix this?

I tried to run a small sample game code in the emulator but it crashed. My LogCat is given here. Can you help me resolve the issue.

02-23 15:18:50.543: D/AndEngine(636): MainActivity.onCreate @(Thread: 'main')
02-23 15:18:50.633: D/dalvikvm(636): Trying to load lib /data/data/com.example.gamegles2demo/lib/libandengine.so 0x40513d70
02-23 15:18:50.633: D/dalvikvm(636): Added shared lib /data/data/com.example.gamegles2demo/lib/libandengine.so 0x40513d70
02-23 15:18:50.633: D/dalvikvm(636): No JNI_OnLoad found in /data/data/com.example.gamegles2demo/lib/libandengine.so 0x40513d70, skipping init
02-23 15:18:50.903: D/AndEngine(636): MainActivity.onResume @(Thread: 'main')
02-23 15:18:50.953: D/AndEngine(636): MainActivity.onPause @(Thread: 'main')
02-23 15:18:50.953: D/AndEngine(636): MainActivity.onDestroy @(Thread: 'main')
02-23 15:18:50.983: D/AndEngine(636): UpdateThread interrupted. Don't worry - this EngineDestroyedException is most likely expected!
02-23 15:18:50.983: D/AndEngine(636): org.andengine.engine.Engine$EngineDestroyedException 02-23 15:18:50.983: D/AndEngine(636): at org.andengine.engine.Engine.throwOnDestroyed(Engine.java:574) 02-23 15:18:50.983: D/AndEngine(636): at org.andengine.engine.Engine.onTickUpdate(Engine.java:560) 02-23 15:18:50.983: D/AndEngine(636): at org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)
02-23 15:18:50.983: D/AndEngine(636): MainActivity.onDestroyResources @(Thread: 'main')
02-23 15:18:50.994: D/AndEngine(636): MainActivity.onGameDestroyed @(Thread: 'main')
02-23 15:18:51.073: D/AndEngine(636): MainActivity.onCreate @(Thread: 'main')
02-23 15:18:51.093: D/AndEngine(636): MainActivity.onResume @(Thread: 'main')
02-23 15:18:51.643: D/libEGL(636): egl.cfg not found, using default config
02-23 15:18:51.653: D/libEGL(636): loaded /system/lib/egl/libGLES_android.so
02-23 15:18:51.803: W/dalvikvm(636): threadid=10: thread exiting with uncaught
exception (group=0x40015560)
02-23 15:18:51.803: E/AndroidRuntime(636): FATAL EXCEPTION: GLThread 13
02-23 15:18:51.803: E/AndroidRuntime(636): java.lang.IllegalArgumentException: No EGLConfig found!
02-23 15:18:51.803: E/AndroidRuntime(636):  at org.andengine.opengl.view.ConfigChooser.chooseConfig(ConfigChooser.java:183)
02-23 15:18:51.803: E/AndroidRuntime(636):  at org.andengine.opengl.view.ConfigChooser.chooseConfig(ConfigChooser.java:157)
02-23 15:18:51.803: E/AndroidRuntime(636):  at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:919) 02-23 15:18:51.803: E/AndroidRuntime(636): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1264)
02-23 15:18:51.803: E/AndroidRuntime(636):  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118) 02-23 15:18:52.294: D/AndEngine(636): MainActivity.onPause @(Thread: 'main') 02-23 15:18:54.404: D/AndEngine(636): MainActivity.onDestroy @(Thread: 'main') 02-23 15:18:54.464: D/AndEngine(636): UpdateThread interrupted. Don't worry - this EngineDestroyedException is most likely expected! 02-23 15:18:54.464: D/AndEngine(636): org.andengine.engine.Engine$EngineDestroyedException
02-23 15:18:54.464: D/AndEngine(636):   at org.andengine.engine.Engine.throwOnDestroyed(Engine.java:574)
02-23 15:18:54.464: D/AndEngine(636):   at org.andengine.engine.Engine.onTickUpdate(Engine.java:560)
02-23 15:18:54.464: D/AndEngine(636):   at org.andengine.engine.Engine$UpdateThread.run(Engine.java:820) 02-23 15:18:54.494: D/AndEngine(636): MainActivity.onDestroyResources @(Thread: 'main') 02-23 15:18:54.494: D/AndEngine(636): MainActivity.onGameDestroyed @(Thread: 'main')  ## 1 Answer It's not going to be easy. I don't know much about AndEngine, but I've developed some GLES 2 apps, and it is possible to run and test them inside an AVD (in the Android world, "Virtual Device", or AVD is the correct term, not "emulator"). Looking at the logcat, I can see that there is a first exception: 02-23 15:18:50.983: D/AndEngine(636): org.andengine.engine.Engine$EngineDestroyedException


However, not only the program seems to continue running, but also the previous line says

UpdateThread interrupted. Don't worry - this EngineDestroyedException is most likely expected!

So the problem is not there. After a few lines you see the real error:

02-23 15:18:51.803: E/AndroidRuntime(636): java.lang.IllegalArgumentException: No EGLConfig found!


Searching google for this error led me here. The main problem is clearly stated in that thread:

The emulator only allows GLES 1 as far as i know.

That is not strictly true, but for AndEngine it probably is.

The problem with GLES 2 and AVDs is that the programmable pipeline of GLES 2 requires a GPU, and the graphics acceleration support in AVDs is disabled by default, and support for it is at best experimental:

Caution: As of SDK Tools Revision 17, the graphics acceleration feature for the emulator is experimental; be alert for incompatibilities and errors when using this feature.

So the first thing you can try is to create an AVD with the latest firmware you can find. Unfortunately, even though this may work, the game will probably be running reeeeally slow. The reason behind this is that the main platform for Android development is ARM, and with almost complete certainty, your development workstation is based on x86 or x86_64, both of which are extremely different from ARM.

So what the AVD framework does is emulate an ARM CPU and some unknown GPU. Even my Core i7-3770 Ivy Bridge is not up to the task of doing that in real time.

But fear not! Android is by itself multiplatform. You can create an AVD using an x86 image (look for it in the SDK manager), and enable virtualization on your computer's CPU so the AVD runs on the actual CPU without the need for emulation. The key to enabling CPU virtualization for AVDs is called HAXM (look for it in the Android SDK manager, but make sure you install it manually. The SDK manager only downloads it for you, but you have to install it yourself)

The best thing about HAXM is that it also allows for GPU virtualization, which means that GLES 2 will run at full speed in your AVD, which greatly simplifies development and testing.

There are two limitations with x86 AVDs with HAXM though:

1. HAXM is a technology developed by Intel. This will most likely not work on AMD CPUs, but I haven't tested that myself.

2. Even though the Android OS is multiplatform by itself, and Java is meant to be multiplatform, code built with the NDK is meant to target a single platform. In general this means that if your code is in Java (or in Mono), you will have no problems making and running it in your accelerated x86 AVD.

However, if you use the NDK, you have to build your native code for x86 as well. Most library developers don't do that out of laziness, and because of that, their code won't run on any x86 devices like the x86 AVD, but also on the increasingly available x86 Android phones like those from Dell, Motorola and Lenovo.

The bad news is that AndEngine seems to use the NDK. I'm saying that because the logcat you provide shows the OS attempting to load a library called libandengine.so. The .so extension is almost exclusively used by NDK modules.

I peeked at the AndEngine code, and it seems that the native stuff they do is quite minimal, so it will likely cleanly build for x86. But unless x86 is a supported platform, the stock AndEngine will not run on HAXM.