How to run your jme3 application on Android – AndroidHarness

I just checked in a change to log more info about the choosen egl config and a check for opengl es 2.0



In logcat look for:

EGL_RENDERABLE_TYPE = %d

Should be 7 for opengl es 2.0 (bit 3 set)



@actsweird: good find!

Since yesterday the SolidColor is depreciated and reports an error if used

Wow, that were some quick responses. :slight_smile:



@normen Sorry, didn’t mean to nag. This was just a thing I stumbled across. Didn’t mean to insult you. I was just wondering, if I did something wrong. The google android simulator is a mess, if you ask me… :wink: (But well they’re still working on it… at least I hope so…)



@larynx Indeed I noticed this when having a look at the logs. I used ColoredTextured instead and now I’m able to apply a texture to the material. :slight_smile:

actsweird said:
Sorry, didn't mean to nag. This was just a thing I stumbled across. Didn't mean to insult you. I was just wondering, if I did something wrong.

Well, I really meant that you could nag them about it because we'd like to see an OpenGLES2 emulator too ;)

Here is my log data:





06-12 09:39:46.725: INFO/JmeSystem(583): Running on jMonkey Engine 3 ALPHA 0.6 Android

06-12 09:39:46.735: DEBUG/libEGL(583): loaded /system/lib/egl/libGLES_android.so

06-12 09:39:46.755: DEBUG/libEGL(583): loaded /system/lib/egl/libGLES_qcom.so

06-12 09:39:46.775: DEBUG/EGL.oem(583): smi: offset=10000000, len=00700000, phys=0x0

06-12 09:39:46.775: DEBUG/EGL.oem(583): ebi: offset=00000000, len=00800000, phys=0x1d800000

06-12 09:39:46.775: DEBUG/EGL.oem(583): reg: offset=20000000, len=00100000, phys=0xa0000000

06-12 09:39:46.845: INFO/OGLESContext(583): Display EGL Version: 1.0

06-12 09:39:46.845: ERROR/OGLESContext(583): OpenGL ES 2.0 is not supported on this device

06-12 09:39:46.845: INFO/OGLESContext(583): JME3 using best EGL configuration available here:

06-12 09:39:46.855: INFO/OGLESContext(583): EGL_RED_SIZE = 8

06-12 09:39:46.855: INFO/OGLESContext(583): EGL_BLUE_SIZE = 8

06-12 09:39:46.855: INFO/OGLESContext(583): EGL_GREEN_SIZE = 8

06-12 09:39:46.855: INFO/OGLESContext(583): EGL_ALPHA_SIZE = 8

06-12 09:39:46.855: INFO/OGLESContext(583): EGL_DEPTH_SIZE = 16

06-12 09:39:46.865: INFO/OGLESContext(583): EGL_STENCIL_SIZE = 0

06-12 09:39:46.865: INFO/OGLESContext(583): EGL_RENDERABLE_TYPE = 0

06-12 09:39:46.885: INFO/AndroidHarness(583): onStart

06-12 09:39:46.885: INFO/AndroidHarness(583): onResume

06-12 09:39:47.065: WARN/dalvikvm(583): threadid=8: thread exiting with uncaught exception (group=0x400207e0)

06-12 09:39:47.095: ERROR/AndroidRuntime(583): FATAL EXCEPTION: GLThread 9

06-12 09:39:47.095: ERROR/AndroidRuntime(583): java.lang.RuntimeException: createContext failed: EGL_BAD_ATTRIBUTE

06-12 09:39:47.095: ERROR/AndroidRuntime(583): at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1077)

06-12 09:39:47.095: ERROR/AndroidRuntime(583): at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1069)

06-12 09:39:47.095: ERROR/AndroidRuntime(583): at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:925)

06-12 09:39:47.095: ERROR/AndroidRuntime(583): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1246)

06-12 09:39:47.095: ERROR/AndroidRuntime(583): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)

06-12 09:39:47.115: WARN/ActivityManager(86): Force finishing activity rds.jme/.MainActivity

06-12 09:39:47.145: INFO/ActivityManager(86): Displayed activity rds.jme/.MainActivity: 1445 ms (total 1445 ms)

06-12 09:39:47.185: INFO/AndroidHarness(583): onPause

06-12 09:39:47.545: INFO/ActivityManager(86): No longer want com.google.android.apps.uploader (pid 17229): hidden #16

06-12 09:39:47.815: INFO/AndroidHarness(583): onStop



I see EGL_RENDERABLE_TYPE = 0



Morris

06-12 09:39:46.845: INFO/OGLESContext(583): Display EGL Version: 1.0
06-12 09:39:46.845: ERROR/OGLESContext(583): OpenGL ES 2.0 is not supported on this device


Seems like your device only supports OpenGLES 1.0, thus you (unfortunately) can't run jmonkey on your device.

Interestingly, my wife’s MyTouch Slide runs all the jme tests except the last two using VA instead of VBO.

did you also get a popup window on the phone saying OGLES 2.0 is not supported?

morrisford said:
Interestingly, my wife's MyTouch Slide runs all the jme tests except the last two using VA instead of VBO.

That's exactly the same behavior my phone is showing. The last two examples just show a black screen (and the performance of the physics example is horrible, but I guess that is due to the bad performance of my device in general).
morrisford said:
Interestingly, my wife's MyTouch Slide runs all the jme tests except the last two using VA instead of VBO.

It appears the Slide has slightly different processor specs. Also, are you sure she's got the 3G, and not the 4G version?
http://www.phonearena.com/phones/compare/T-Mobile-myTouch-3G,T-Mobile-myTouch-3G-Slide,T-Mobile-myTouch-4G-Slide/phones/4427,4395,5467

@larynx: I am not sure if it matters, but there’s a difference between EGL version and OGLES version, the maximum possible version for EGL is only like 1.4 right now

Yes, i know, its a bit misleading in the log.



To check for OpenGL ES 2.0 i do (EGL_RENDERABLE_TYPE & EGL_OPENGL_ES2_BIT) != 0



In his case its not even opengl es 1.0, because bit 1 is not set ether. Strange

I got a strange error when trying to run HelloAssets tutorial example on Android, it seem to stumble on

[java] Spatial ninja = assetManager.loadModel(“Models/Ninja/Ninja.mesh.xml”);[/java]

That for some reason makes SkeletonLoader.java use the skeleton object before it is initialized, e.g. skeleton is still “null” when that “track” start tag is found. I can see that it should be initialized when the end of the “bonehierarchy” tag is found, I verified this by adding breakpoint on both the endElement() in the “bonehierarchy” section and startElement() in the “track” section and the “track” is invoked first.



Looking in into Ninja.skeleton.xml everything seem to be in the right order:

[xml]



<bonehierarchy>

<boneparent bone=“Joint2” parent=“Joint1” />



</bonehierarchy>

<animations>

<animation name=“Attack1” length=“1”>

<tracks>

<track bone=“Joint1”>



[/xml]

I can also see that it finds start of the “bonehierarchy” tag and the “boneparent” tags.



Could it be some different behavior in the XML parser used? Or have I found a old version of something. Using SVN from the first post in the thread. (could not find anything in the SVN history indicating this).

Ill see if I manage figure out what happens…

Some more digging…

Seems like in

[java]public void endElement(String uri, String name, String qName) {[/java]

qName is always null and name gets the end tag name.

In

[java]public void startElement(String uri, String localName, String qName, Attributes attribs) throws SAXException {[/java]

both localName and qName get the tag name.

I changed to code to use name/localName instead of qName it get passed the XML problem, I know to little about XML to know if this is the proper way to fix it but it helped me.

Added an issue with a patch here

http://code.google.com/p/jmonkeyengine/issues/detail?id=361

EDIT 2011-06-20 Added issue/patch link

Its really strange that qName is null. Did you test your patch when running on desktop jme?

I’ve done a bit of digging myself, and I found that the bones array is empty prior to creating a skeleton object which results in a null pointer exception.

this can be fixed by creating one in startElement method:

[patch]### Eclipse Workspace Patch 1.0

#P jme3

Index: src/ogre/com/jme3/scene/plugins/ogre/SkeletonLoader.java

===================================================================

— src/ogre/com/jme3/scene/plugins/ogre/SkeletonLoader.java (revision 7654)

+++ src/ogre/com/jme3/scene/plugins/ogre/SkeletonLoader.java (working copy)

@@ -128,6 +128,15 @@

animation = new BoneAnimation(name, length);

} else if (qName.equals(“bonehierarchy”)) {

assert elementStack.peek().equals(“skeleton”);

  •        Bone[] bones = new Bone[indexToBone.size()];<br />
    
  •        // find bones without a parent and attach them to the skeleton<br />
    
  •        // also assign the bones to the bonelist<br />
    
  •        for (Map.Entry&lt;Integer, Bone&gt; entry : indexToBone.entrySet()) {<br />
    
  •            Bone bone = entry.getValue();<br />
    
  •            bones[entry.getKey()] = bone;<br />
    
  •        }<br />
    
  •        indexToBone.clear();<br />
    
  •        skeleton = new Skeleton(bones);<br />
    

} else if (qName.equals("animations")) {

assert elementStack.peek().equals("skeleton");

animations = new ArrayList<BoneAnimation>();

[/patch]

Hrm I fuc*ed up my build in some way, I don’t manage to do someting like “make clean” “make” for the desktop version. For some reason it will not rebuild my application. I deleted it by hand and now I don’t even have one, I have tried various combination of "ant ". Ill try some more to see if I can figure out what am doing wrong, or Ill download a new version and patch it before I build to verify my patch on the desktop version. Basically what I want to check in the desktop version is if startElement() “localName” and endElement() “name” is the same string as qName.



Also when I say null above I probably don’t mean null but the empty string e.g “”.

Take care!

@kabuki: I am trying to understand what the difference is between android and desktop handling of XML, it would be useful to find out what causes the bug so that a proper fix can be made rather than finding workarounds.

Could someone upload a project file (that i can open and compile)

or post some more code of a project that does something?



Perhaps, the simple application (the blue box). I’m trying to get this setup working but my apk’s are crashing.

and I don’t know if it’s my poor coding or my project setup.



I’m new to java and jMonkey, but my nook color runs the jmonkey tests downloaded from market fine - (except the last 2 tests)



Any help is appreciated, thanks

If you send me your email per pm i can send you my eclipse project i use for testing.

Larynx



Can you post the entire eclipse project online somewhere?



A simple hello world cube using jme with all code and libraries in one zip will really help kickstart stuff on the android platform.



I have burned hours trying to get a simple android application using jme to work.