Android Studio emulator problem

Our entire 4th year class are having emulator issues. Our lecturer is still having issues after months. I use a real phone, doesn’t have any issues. Best advice is save yourself the suffering and just use a android phone attached to i presume your android studio. Works with no issues for me and everyone in class always

I can’t see GLES 3 option there. Try to update emulator using sdk manager then check it again.


This config works for me.

@hgokturk are you using Android Studio 3.0.1 ?
Where’s located “Extended controls” window? Please tell me step by step.
Remember, I’m using high Sierra, not windows.

Yes it’s Android Studio 3. Settings of emulator.

I just want to report that I’m seeing the same issue when running cpptests under the emulator.

Initially just black screen with the 0x501 errors. After I added mediump to COCOS2D_SHADER_UNIFORMS in CCGLProgram.cpp following domp’s advice, the tests actually run, however the same errors are still printed to the Gradle Console.

High Sierra 10.13.3
Android Studio 3.0.1
cocos2d-x-3.16

x86 target

Android emulator is very problematic lately.

I still didn’t resolve the problem. If anyone find a solution, post here :wink:

Our lecturer recently fixed it for our class. He was trying for months. I can share what he told us do, assuming you have all other things working.
He added couple lines in this file where ever it is in the cocos library and it sorts issues

Something got do wth opengl or android emulator rendering thing or something GLES I think

CCGLProgram.cpp (35.5 KB)

I think this is the file that he added a couple lines code in somewhere and then emulator worked . no idea where it goes. i can ask him if anyone wants me to in email. Let me know

1 Like

The file works for me. It is located in cocos2d/cocos/renderer folder. There are differences around line 486.

The original file:

#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
    headersDef = (type == GL_VERTEX_SHADER ? "precision mediump float;\n precision mediump int;\n" : "precision mediump float;\n precision mediump int;\n");
#elif (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 && CC_TARGET_PLATFORM != CC_PLATFORM_LINUX && CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
    headersDef = (type == GL_VERTEX_SHADER ? "precision highp float;\n precision highp int;\n" : "precision mediump float;\n precision mediump int;\n");
#endif

And the new file:

#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
        headersDef = (type == GL_VERTEX_SHADER ? "precision mediump float;\n precision mediump int;\n" : "precision mediump float;\n precision mediump int;\n");
#elif CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
        headersDef = "#version 100\n precision mediump float;\n precision mediump int;\n";
#elif (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 && CC_TARGET_PLATFORM != CC_PLATFORM_LINUX && CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
        headersDef = (type == GL_VERTEX_SHADER ? "precision highp float;\n precision highp int;\n" : "precision mediump float;\n precision mediump int;\n");
#endif

@slackmoehrle, I think you should consider integrating this change in the project. Now my game runs just fine in the Android Studio emulator with default settings. It is really helpful for me since I can now test a multiplayer session between my phone and the emulator. I do not need my wife’s phone anymore :smile:

The file works for me too, but sometimes I continue with problems. Example when I replace scenes or try to open google play game services. Really it’s the final solution? maybe it should be evaluated by cocos team.

I am replacing scenes and using Google Play Games Services in my game too, and everything is working in the emulator. Is your game working well on devices?

Yep, in the device works. Anyway, i will try with another emulator.

Is there any updated version of CCGLProgram.cpp for cocos 2.2.6?

Thanks for @yinjimmy for updating Cocos2dx 2.2.6 CCGLProgram.cpp code here