Problem building/running on Android (emulator)

Do you use at least Android API 16 in the emulator? Do you have host GPU support enabled?

This is my emulator.
It should be right

It is a black screen but the game is running, because if I try some “blind” clicks I can hear the tiles movement sound effect.

I repeat, thank you very much for your support, but don’t worry too much for me, you have probably more important things to take care of.

Cheers :wink:

1 Like

I could more information here:

You might try a newer Android API version (not sure that would help), that you might try an X86 processor for the emulator, and, I’m not sure if there might be other settings that interact with the “host GPU” setting, which is essential for OpenGL ES 2 support to work properly. Please let us know if you make progress, and helping is important :wink:

I’ll try later for sure both ways and let you know.

Also I want to take the opportunity to thank you again for the support but especially for your work. I’m having a lot of fun and challenge learning and playing with OpenFL.
Thanks a lot mate, you are a great man.

see ya later

Ok, nothing!

I’ve installed API21 and put in my project.xml

<android target-sdk-version="21" />

I’ve setup a different emulator with Google API 21 and x86 (and obviously installed IntelHAXM) and put in my project.xml

<compilerflag name="-DHXCPP_X86" if="x86" />
<architecture name="x86" if="x86" />

I compile with no issues, the app come to the emulator with the following commands
terminal1

cd to/your/androidsdk/
emulator -avd adtest

terminal2

cd to/your/project
lime test android -emulator -debug

what I get is a blank screen
I can see the background color in one screen when I “draw” a Bitmap rotated (I can see the triangles on the edges colored as the bgcolor).
I suppose every sprite get blitted black.

(sound works, touch_input works)

What can I do?

Confirm that for Genymotion (android-x86).
Text - ok, shapes - ok. But every sprite is black.

thank you restorer, this means there is a real bug with android target.
(btw very interesting this genymotion, i’m downloading it right now ;))

Just to note: bug only for x86, arm work just fine.
(I test on real device)

I’ve successfully used Android apps on an x86 emulator, though a bummer that they didn’t make that work properly for AMD processors, so totally subjective :frowning:

I’m guessing that Genymotion does not use “host GPU” quite the same as the normal emulator, and thereby must be having a GL error of some kind

It’s definitely something with Bitmaps, because text and shapes work just fine in genymotion.
Moreover:

It is raw OpenGLView. Image displayed just fine.
Also background is not an image, but fragment shader.

I wonder if there’s a way to debug, if it’s hitting an OpenGL error

I’ll try to dig into it. I guess it should be somewhere in lime legacy? Can you point me on files, where I should start looking.

Do you get any logs back on the emulator? I think Android tends to report “GL error:” at times

Currently I’m not near my computer. Will look in logcat tomorrow.

Got logcat:

E/NME     (  952): GL Error: 1280 7x9
E/NME     (  952): GL Error: 1280 12x17
E/NME     (  952): GL Error: 1280 13x17
E/NME     (  952): GL Error: 1280 12x17
E/NME     (  952): GL Error: 1280 13x17
E/NME     (  952): GL Error: 1280 15x17

Where 1280 is GL_INVALID_ENUM

Sadly, OpenGL is pretty passive about errors. It sets an error flag whenever something goes wrong, and it’s up to you to check it.

Here are some functions to make your life easier:

public static inline function checkGLError(?posInfos:haxe.PosInfos):Void {
    var error:Int = GL.getError();
    if(error != GL.NO_ERROR) {
        haxe.Log.trace("GL error: " + getErrorDescription(error), posInfos);
    }
}
public static function getErrorDescription(error:Int):String {
    switch(error) {
        case GL.NO_ERROR:
            return "NO_ERROR";
        case GL.INVALID_ENUM:
            return "INVALID_ENUM";
        case GL.INVALID_OPERATION:
            return "INVALID_OPERATION";
        case GL.INVALID_FRAMEBUFFER_OPERATION:
            return "INVALID_FRAMEBUFFER_OPERATION";
        case GL.INVALID_VALUE:
            return "INVALID_VALUE";
        case GL.OUT_OF_MEMORY:
            return "OUT_OF_MEMORY";
        default:
            return Std.string(error);
    }
}

Call checkGLError() after every OpenGL operation, and it’ll tell you when and where something is going wrong. (Make sure you don’t supply the posInfos parameter. Haxe will fill that in automatically.)

Once you figure out which OpenGL function is causing it, look up that function online. The man page will tell you why that function would cause that error.

Actually I don’t have any problems with opengl - when I use raw OpenGLView all works perfectly, including any textures and complex shaders.

Probles is with OpenFl itself - it can’t display a bitmap on android-x86 (at least on emulator)

@singmajesty Any thoughts about this? I want to help track it down, but I need directions where to look.

What we have:

  • Everything works fine on android-arm
  • Everything except bitmaps work fine on android-x86
  • Host GPU is used
  • No problems when using GL.blahblah to load texture and display it
  • No problems with custom shaders (using GL.blablabla)
  • The only problem - displaying Bitmap (for example, when addChild(myBitmap)) (draw tiles also renders black boxes)

Actually I’ve got the same problem (bitmap black) on ARM and X86.
So the first line of your recap (everything’s fine on ARM) doesn’t apply to me
(API21, Host GPU yes)

I suppose it’s only an EMULATOR problem, but I can’t test on a real device right now

example on ARM emulator (same as x86)
What you see are lines on a sprite (there are a lot of BITMAPS around that are drawn BLACK)