Android Studio emulator problem


#1

Hi all,
I’m having problems for run apps in android emulator. In a real device works but in a emulator not. This is the error log when I’m trying to run the app:

Emulator: android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glGetUniformLocation:2533 error 0x501

Anyone know what’s the problem? I tried with differents device emulators, but nothing works.
I’m running Android Studio 3.0.1 in iMac (High Sierra)
P.S.: I installed the sdks, ndks, jre, HAXM, etc.


#2

Here are the specs of the emulator:

Name: Galaxy_Nexus_API_27

CPU/ABI: Google APIs Intel Atom (x86)

Path: /Users/tranthor/.android/avd/Galaxy_Nexus_API_27.avd

Target: google_apis [Google APIs] (API level 27)

Skin: galaxy_nexus

SD Card: 100 MiB

hw.dPad: no

hw.lcd.height: 1280

runtime.network.speed: full

hw.accelerometer: yes

hw.device.name: Galaxy Nexus

vm.heapSize: 80

skin.dynamic: yes

hw.device.manufacturer: Google

hw.lcd.width: 720

hw.gps: yes

hw.initialOrientation: Portrait

image.androidVersion.api: 27

hw.audioInput: yes

image.sysdir.1: system-images/android-27/google_apis/x86/

tag.id: google_apis

showDeviceFrame: yes

hw.camera.back: emulated

hw.mainKeys: no

AvdId: Galaxy_Nexus_API_27

hw.camera.front: emulated

hw.lcd.density: 320

avd.ini.displayname: Galaxy Nexus API 27

hw.gpu.mode: auto

hw.device.hash2: MD5:5c288d27461585ecc73a535555e7cf61

hw.ramSize: 1024

hw.trackBall: no

PlayStore.enabled: false

fastboot.forceColdBoot: no

hw.battery: yes

hw.cpu.ncore: 4

hw.sdCard: no

tag.display: Google APIs

runtime.network.latency: none

hw.keyboard: yes

hw.sensors.proximity: yes

disk.dataPartition.size: 1000M

hw.sensors.orientation: yes

avd.ini.encoding: UTF-8

hw.gpu.enabled: yes

The emulator boots fine but when it try to run the app, the display turns black and that’s the error.


#3

UP.
Someone can run Android Emulator (from Android Studio) in a macOS High Sierra 10.13.3 ? It’s impossible for me, I tried different alternatives but nothing works.


#4

I’ve had the same problem after upgrading to high sierra last year (using a hackintosh though), however with a different opengles error. I narrowed it down pretty quickly to this issue by enabling some opengles debug functions (I don’t remember anymore what I did exactly).

Basically go to cocos2d/cocos/renderer/CCGLProgram.cpp line #149 and add mediump

static const char * COCOS2D_SHADER_UNIFORMS =
        "uniform mediump mat4 CC_PMatrix;\n"
        "uniform mediump mat4 CC_MultiViewPMatrix[4];\n"
        "uniform mediump mat4 CC_MVMatrix;\n"
        "uniform mediump mat4 CC_MVPMatrix;\n"
        "uniform mediump mat4 CC_MultiViewMVPMatrix[4];\n"
        "uniform mediump mat3 CC_NormalMatrix;\n"
        "uniform mediump vec4 CC_Time;\n"
        "uniform mediump vec4 CC_SinTime;\n"
        "uniform mediump vec4 CC_CosTime;\n"
        "uniform mediump vec4 CC_Random01;\n"
        "uniform sampler2D CC_Texture0;\n"
        "uniform sampler2D CC_Texture1;\n"
        "uniform sampler2D CC_Texture2;\n"
        "uniform sampler2D CC_Texture3;\n"
        "//CC INCLUDES END\n\n";

Maybe it’ll help.


#5

@domp thanks for your help.
I’ve the same error changing that, however, now I can view the initial scene of my game in the emulator (before this change, the emulator had black screen).

However, then I touch “Play”, the scene is replaced and appears again a black screen in the emulator. I hear the game music, the game is running, but the screen is black.

I read that it’s a Intel HAXM problem with Sierra. I’m not using hackintosh, i’m with a real iMac. I’ve other pc with Windows and the emulators works perfect, and i’ve the same configuration in android studio.

I would like solve it with some configuration, without editing any cpp file from cocos. I think it isn’t a cocos framework problem. @zhangxm ? @slackmoehrle ? Maybe anyone lived it :sweat:


#6

Alright so your initial scene works now, that’s a start. I’m pretty sure that the game showing a black screen after pressing play is a different error caused by the game itself. You should be able to narrow it down by commenting out bits of code in your play function and whatever nodes you are creating in the new scene.

I’ve had black screens and opengles errors like that a few times, turned out to be some minor mistake like creating a sprite with an invalid texture, or creating a node from a different thread etc.

Also the previous fix I mentioned was acknowledged and should hopefully be fixed properly with 3.17 (it actually affects real devices), so you should only keep it in when trying out the emulator for now.


#7

Nope, my game works fine. I tested it in some real iPhones and in a real Androids devices. Works perfect. The problem is specifically in a Android Emulator running on High Sierra 10.13. Even, as I mentioned before, in a Android Emulator running in Windows, works perfect.


#8

Well, it might work just fine on real devices and on windows, yet you could still have made a mistake somewhere that only the android emulator on mac os complains about. I can only advise you to just try commenting some parts out, at least that’s what I would do. Something you are doing inside your play function or creating in the new scene has to undeniably cause this after all. Unless of course the Director’s replaceScene() function itself is causing the screen to go black.


#9

No, after replaceScene() I continue viewing the screen. However I continue executing step by step and I don’t find in what line the screen transforms in black. Even, I entered to cocos frameworks instructions for debug step by step but I arrive to the file __functional_base.h and I can’t continue debugging step by step.

Is very hard debug it and i’m sure that isn’t my code the problem. Are much the Android real devices that I tested succesfully it.

In addition, the modification that you have proposed is editing a cocos cpp file, and i view some results editing that. That’s a demostration that isn’t my code the problem.


#10

Yes, that’s expected. Debugging by stepping through execution is a good practice in most cases, but not in this one since the renderer will not update when you step through your code but instead inside his own timer outside of your scene creation/play function. You’ll have to resort to removing things manually unfortunately.

Or here’s an even simpler way to verify that your scene is causing the black screen: Create a new bare minimum scene with a label in the middle to verify that everything is working, and replace the initial scene with that one instead. If it still shows a black screen I’ll admit I was completely wrong.


#11

Before the initial menu scene, exist the splash screen in my game. The transition between scene1 and scene2 is automatic.
This is the sequence:
Scene1 -> Splash screen.
Scene2 -> Initial menu.
Scene3 -> After pressing Play button.

With ur modification, scene1 and scene2 works. So, replaceScene isn’t a problem.
Thanks for your help, but I completely discard a problem in my code. Why it works in Android emulator in windows and not in android emulator in Sierra? Both emulators have the same configuration. And my code is the same. Is ilogic. If I the problem is my code, it should fail in both emulators. The problem is the OS.


#12

At this point you could only send me a minimal project that reproduces the black screen and I’ll take a look at it next week, otherwise I can’t assist any further without repeating myself.


#13

I trust @zhangxm will have a magical answer for me :sunglasses:


#14

I have never, ever gotten a single emulator to work for me. I just always use a real device, sorry :frowning:


#15

@tranthor did you add x86 in APP_ABI? And what’s your engine version?


#16

Yes, in gradle.propierties I’ve this: PROP_APP_ABI=armeabi:x86
Android Studio 3.0.1
Cocos2d-x-3.16


#17

I think you should change gradle.properties to PROP_APP_ABI=armeabi x86. Don’t need : between armeabi and x86.


#18

Nop, it’s ok the syntax. Maybe you confunse it with the Application.mk configuration. In that file I can put:
APP_ABI := armeabi x86

But that’s not the problem.


#19

Try GLES 3 in emulator (advanced)settings?


#20

This?
Captura

I tested both GLES but nothing…