[Fixed] GLES2.0 on Android

Hello, guys

When i try to test cocos2d on Android, in the java file, Cocos2dx cannot find GLES2.0
I`m using Mac and it`s play fine on iOS. Anyone had the same problem?

Thanks (:

Which Android SDK version did you use?
Android supports OpenGL ES 2.0 since 2.2.

Any error log?

I`m building for Android 2.2. I read that only emulator with Android 4.0.3 or major with gpu option on can run GLES2. True? I`m testing with emulator running Android 2.2, 4,0.3 or 4.1 and I got the error “don’t support gles2.0”.

Thanks!

I too am getting the “don’t support gles2.0” log message when running the Android 4.0.3 and 4.1 emulators. They are apparently supposed to support OpenGL ES 2.0.

I have tested my app on emulator, and i get same error too. But my app work fine in real devices.

In a real device, my app work fine too. ;S

Thanks.

Hi,
this is my first post on cocos2dX forum…:slight_smile:
i think you need to set two things: set Hardware-emulation property of AVD to true.
and in your project’s manifest add this line.

 "< uses-feature android:glEsVersion="0x00020000" android:required="true" />"

Best,

Please take a look at this issue (link to ticket #1387)
You may need to add:
|| Build.FINGERPRINT.startsWith("generic")
to the AplicationDemo::detectOpenGLES20 method if testing on an emulator.

The emulator should at least have the target version Android 4.0.3 - API Level 15.
The GPU Emulation property should be set to yes
Alternately, you can launch the emulator with the command line option -gpu on [Ref]

Thanks, PAT RZ2. Fixed.

hello guys,
i tried almost all the suggestions:

1-
2- //added this line in the java class,
if (detectOpenGLES20()) {
……
Build.FINGERPRINT.startsWith(“generic”);<—
}
3- added the GPU emulation (property) set to YES - see screenshot

and i m still getting the “don’t support gles2.0” in the logcat ,

anything am missing ?1

please note that i am using the cocos2d-2.0-rc0a-x-2.0 library build.

thanks

Hellooo, Rabih

Into detectOpenGLES20, you need return “(info.reqGlEsVersion >= 0x20000 || Build.FINGERPRINT.startsWith(”generic“));”

Do you tried this?

thank you very much - it worked ….

private boolean detectOpenGLES20()
{
ActivityManager am =
(ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
ConfigurationInfo info = am.getDeviceConfigurationInfo();
return (info.reqGlEsVersion >= 0x20000 || Build.FINGERPRINT.startsWith(“generic”));
}

this is how the final function looks like.

sorry if my reply came very late

I’ve got same error when trying to launch app on emulator.
12-04 08:03:13.792: E/AndroidRuntime(1081): FATAL EXCEPTION: GLThread 105
12-04 08:03:13.792: E/AndroidRuntime(1081): java.lang.IllegalArgumentException: No config chosen
12-04 08:03:13.792: E/AndroidRuntime(1081): at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:874)
12-04 08:03:13.792: E/AndroidRuntime(1081): at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1024)
12-04 08:03:13.792: E/AndroidRuntime(1081): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1401)
12-04 08:03:13.792: E/AndroidRuntime(1081): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

I’m using cocos2d-2.0-x-2.0.4

I set in manifest.
I turned on gpu emulation for AVD (see attached screenshot).
I use API level 17 for AVD
I cannot find method detectOpenGLES20 in my project (I used Ctrl + H and File Search to find it in my porject).
What is a reason of that problem?
How can I fix it?
Thank you

Rabih harb wrote:

thank you very much - it worked ….
>
private boolean detectOpenGLES20()
{
ActivityManager am =
(ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
ConfigurationInfo info = am.getDeviceConfigurationInfo();
return (info.reqGlEsVersion >= 0x20000 || Build.FINGERPRINT.startsWith(“generic”));
}
>
this is how the final function looks like.

Where this method located?

detectOpenGLES20 exist in the “src” folder of your project

in a package like com.cocos2dx.yourappname

in a file called youappname.java

hope it will save you some headache

There is no detectOpenGLES20 method in my project, I think this is because I use v 2.0.4 of cocos2d-x.
Thank you for answer.
I will try to fix this problem.

I solved this rpoblem by adding

gLSurfaceView.setEGLConfigChooser(8 , 8, 8, 8, 16, 0);

before

gLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());

in Cocos2dxActivity.java

Now my app runs on emulator.

Screenshot contains config for AVD

Petr Bodnar wrote:

I solved this rpoblem by adding
>
gLSurfaceView.setEGLConfigChooser(8 , 8, 8, 8, 16, 0);
>
before
>
gLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());
>
in Cocos2dxActivity.java
>
Now my app runs on emulator.
>
Screenshot contains config for AVD

Hi. Is it safe? Did you test on other devices? This problem appears on Adreno 200 devices.

I dont know if it safe to run on the devices.
What problem appears on Adreno 200?
Does your app works with gLSurfaceView.setEGLConfigChooser(8 , 8, 8, 8, 16, 0); on that device?
I test only on emulator, with different screens.
I will try to test this on Android devices today.

I can confirm I encountered Petr Bodnar issue yesterday while debugging one of my apps and applied same fix with success.
Could somebody create an issue so that we submit a proper patch ?
We need to find a way to properly detect or set we are running on simulator.