How to Activate OpenGLES 2.0 in Android Emulator

Most of the Application Developers who wants to learn basics of OpenGLES architecture will find and try to execute the Hello OpenGLES sample provided by Android.

And there are two variants of the sample, one for OpenGLES version 1 and the other, OpenGLES version 2. So, almost everyone try to use the version 1 will successfully run the sample, and nearly all will fails for version 2 on first try.

If you try to search in the net of how to resolve the version 2 problem, you will find there are many confusing stories, that will cause frustration and will believe that OpenGLES version 2 is not supported in the emulator.

There are also suggestion to call setEGLConfigChooser, but it requires right condition to be effective.

The key is to pay attention to the log file given by the emulator during start up. Here is the indication that something wrong for OpenGLES 2.0 support in the emulator:


Emulator can still be run at this condition, and this will have some effect at the Android application side, which some indication in the logcat as follows:


If the Android Framework is forced to use, then it is game over. You will be stuck in OpenGLES version 1 forever. The setEGLConfigChooser will useless, because the error will be triggered at Android GL java runtime before the setEGLConfigChooser is executed. Usually the error message is “No configs match configSpec”.

If you get the above error message, this indicated that your emulator is still using and only can operate in OpenGLES version 1.

Here, you should make sure that the emulator is capable to support version 2 by eliminating the above error message from emulator by supplying the requested DLL. But part of the difficulty lies in the error message from emulator which is rather un-informative.

The missing DLL is actually libOpenglRender.dll and this dll also requires other dll. So, please make sure that libGLES_V2_translator.dll, libGLES_CM_translator.dll and libOpenglRender.dll is present in the same directory as the emulator program.

Sign of healthy emulator that’s ready for OpenGLES 2.0 support is indicated by the log below:


You can notice that emulator now adds new switch called qemu.gles with 1 as its value. This will cause the Android Framework to use different library because it checks the presence of ro.kernel.qemu.gles and if the value is 1 it will use different library set as indicated by the log below:


But the Hello OpenGL ES 2.0 still have some problem with “no config chosen” error:


Let’s retrieve the logcat:


Here’s the logcat result:


To get more information about the nature of the error, I’ve created the Netbeans project for existing Android Java Framework as follows:


Adds the source package from starting at D:\Projects\Android\Frameworks\Base\opengl\java


Should set the application to stop execution waiting for debugger:


Execute the application, we will have this screen:


Examine the process attribute and noted down the PID:


Perform port forwarding for the noted PID value:


In Netbeans attach to the process:


Now it will stopped at intended breakpoint:


So the problems lies inside chooseConfig on which insist on getting config with satisfying mAlphaSize is zero. All of the available alpha size from the emulator is 8.

So why this mAlphaSize is created with zero value ? To find it, here is the call stack at the time of class instance call:


And the function call appears to be hardcoded:


Here the call to setEGLConfigChooser will get some effect this time, because it will override the default one given by the Framework:


Perform re-compilation:


Re-installation process:


See that it can be run this time:


Q.E.D šŸ™‚


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: