[SOLVED] Basic JME3 Android Gradle Script

Hello Guys,
I’m starting to convert my JME3 based game engine (www.scenemax3d.com) to Android. I’m using Android Studio and would like to add JME implementations to the gradle build file So…
Can anyone point me to a gradle build script for Android JME application with support for Minie physics and GLTF loader? Also did anyone tried to run sgold’s JME-Vehicles and SkyControl on Android devices ?

Thanks a lot!

2 Likes

Check this :-

& this one :

Yes, Minie works on the first example above, but I am not very sure about the GITF loader, if it’s loading gITF files without converting j3o, then it also works fine out of the box, but you need to place assets inside Android asset folder…

About Jme-Vehicles, i have started working on android version of it, it works after removing most of Lemur PropertyPanels & TabBar Menus, i cannot remember now what was that problem that caused me to do this, anyway i have plans to build a new HUD using android views… with high performance binding to Android Sensors, which already made a good success as of demoApp linked above…but i haven’t released it on git yet !

NB : it wasn’t sgold’s version that i have tried on android, it was jayFella’s…(old version)

EDIT : i was to upload new android examples for jme3.4.0, but there was some disturbances with git & my network was limited, so those are the very simple examples if you want :

Covered AndroidHarness, FragmentHarness, JmeSurfaceView, Jme~Android native UI (Android Views).

3 Likes

Thanks a lot Pavel. I will take a look

3 Likes

Continue with the Android porting…
I have problem with some dependencies:
in the report below we see that org.jmonkeyengine:jme3-lwjgl:3.3.2-stable and com.github.stephengold:MaVehicles:0.6.0 are dependent on org.jmonkeyengine:jme3-desktop
Therefore I cannot use them in the Android project.
Question for @sgold is it possible to avoid the desktop dependency for the MaVehicle lib? it is because of using the com.atr:jme-ttf:2.2.2
And @Pavl_G how do you include org.jmonkeyengine:jme3-lwjgl:3.3.2-stable in your gradle if it depends on org.jmonkeyengine:jme3-desktop?

+--- org.jmonkeyengine:jme3-lwjgl:3.3.2-stable
|    +--- org.jmonkeyengine:jme3-core:3.3.2-stable
|    +--- org.jmonkeyengine:jme3-desktop:3.3.2-stable
|    |    \--- org.jmonkeyengine:jme3-core:3.3.2-stable
|    \--- org.lwjgl.lwjgl:lwjgl:2.9.3
|         +--- org.lwjgl.lwjgl:lwjgl-platform:2.9.3
|         \--- net.java.jinput:jinput:2.0.5
|              \--- net.java.jutils:jutils:1.0.0
+--- commons-io:commons-io:2.0.1
+--- com.github.stephengold:MaVehicles:0.6.0
|    +--- org.jmonkeyengine:jme3-core:3.3.2-stable
|    +--- org.jmonkeyengine:jme3-effects:3.3.2-stable (*)
|    +--- com.atr:jme-ttf:2.2.2
|    |    +--- org.jmonkeyengine:jme3-core:[3.1,) -> 3.3.2-stable
|    |    +--- com.jaredrummler:sfntly:1.+ -> 1.0.1
|    |    \--- org.jmonkeyengine:jme3-desktop:[3.1,) -> 3.3.2-stable (*)
|    \--- com.github.stephengold:Heart:6.4.2
|         \--- org.jmonkeyengine:jme3-core:3.3.2-stable

Edit: I tried excluding jme3-desktop in the gradle script but it didnt help…

    implementation ("org.jmonkeyengine:jme3-lwjgl:3.3.2-stable") {
        exclude group: 'org.jmonkeyengine:jme3-desktop:3.3.2-stable'
    }
    implementation group: 'commons-io', name: 'commons-io', version: '2.0.1'

    implementation ('com.github.stephengold:MaVehicles:0.6.0') {
        exclude group: 'org.jmonkeyengine:jme3-desktop:3.3.2-stable'
    }
2 Likes

Try excluding from all the configurations you use :

2 Likes

Works!!! Thank you!

2 Likes

As you can see from the graph, the dependancy of MaVehicles:0.6.0 on jme3-desktop is indirect (by way of jme-ttf) and therefore an issue for @Tryder to address.

1 Like

As for lwjgl depending on desktop… lwjgl is a desktop renderer.

…I don’t do android development but I was 99% sure that android apps did not use lwjgl.

Indeed it seems to have its own JME renderer and everything: jmonkeyengine/AndroidGL.java at master · jMonkeyEngine/jmonkeyengine · GitHub

3 Likes

That’s true…but other dependencies may include it implicitly.

Pavel, I saw that lwjgl is added explicitly in your demo app (Superior-Extended-Engine/build.gradle at master · Scrappers-glitch/Superior-Extended-Engine · GitHub)
That’s why I thought it was important. I will remove it from my script and check…

2 Likes

They shouldn’t. Unless you mean non-JME libraries that have messed up their dependencies. That we can’t control except to push back on the author.

Only applications need to depend on a rendering implementation.

2 Likes

Yes, it is wrong & should be removed…, thanks for reminding me

EDIT: I have removed unnecessary dependencies…

2 Likes

Honestly, I really don’t see why I need to be bending over backward here. The fact is your government has made several attempts to assassinate me. To my face you’ll praise my works and ask for more, yet behind my back hire a bunch of hitmen to kill me.

You bought the poison. You bought the guns. You paid their salary. You voted for the people who hired them and gave them the orders.

The source code is on my site. The source code is on github. Download it. Fork it. Fix it up. Whatever, but don’t expect me to do you any favors. This is bullshit.

Sorry to disturb you. I’ll fork the repo, then.

5 Likes

Truely, this has been an eye opening experience.

What are you talking about? Who is trying to kill you?

@Pavl_G did you manage to debug your apps using an emulator or just a physical device?
I’m getting this error (java.lang.IllegalStateException: Framebuffer has erronous attachment) when running an empty application:

I/cenemax3dplaye: Not late-enabling -Xcheck:jni (already on)
E/cenemax3dplaye: Unknown bits set in runtime_flags: 0x8000
W/cenemax3dplaye: Unexpected CPU variant for X86 using defaults: x86
W/ActivityThread: Application com.abware.scenemax3dplayer is waiting for the debugger on port 8100...
I/System.out: Sending WAIT chunk
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
I/chatty: uid=10133(com.abware.scenemax3dplayer) identical 5 lines
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1438)
D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.
W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
W/RenderThread: type=1400 audit(0.0:41): avc: denied { write } for name="property_service" dev="tmpfs" ino=7425 scontext=u:r:untrusted_app:s0:c133,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0 app=com.abware.scenemax3dplayer
D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so
W/cenemax3dplaye: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/cenemax3dplaye: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
I/JmeSystem: AudioRenderer not set. Defaulting to OpenAL Soft
    Running on jMonkeyEngine 3.3.2-stable
     * Branch: HEAD
     * Git Hash: 1a05e3f
     * Build Date: 2020-04-27
I/JmeSystem: AudioRenderer not set. Defaulting to OpenAL Soft
I/com.jme3.system.android.OGLESContext: INFO Android Build Version: 29
D/HostConnection: HostConnection::get() New Host Connection established 0xe2fdb990, tid 8955
    HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 
D/EGL_emulation: eglCreateContext: 0xcc00a600: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0xcc00a600: ver 2 0 (tinfo 0xe2f4f6e0)
W/Gralloc3: mapper 3.x is not supported
D/HostConnection: HostConnection::get() New Host Connection established 0xdfa6f4e0, tid 8958
D/HostConnection: createUnique: call
D/HostConnection: HostConnection::get() New Host Connection established 0xe2fdba80, tid 8955
    HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2 
D/EGL_emulation: eglCreateContext: 0xf667f820: maj 2 min 0 rcv 2
D/eglCodecCommon: allocate: Ask for block of size 0x1000
    allocate: ioctl allocate returned offset 0x3ff1e0000 size 0x2000
D/EGL_emulation: eglMakeCurrent: 0xf667f820: ver 2 0 (tinfo 0xdfa8bf70)
D/EGL_emulation: eglMakeCurrent: 0xcc00a600: ver 2 0 (tinfo 0xe2f4f6e0)
W/cenemax3dplaye: Accessing hidden method Lsun/nio/ch/DirectBuffer;->cleaner()Lsun/misc/Cleaner; (greylist, reflection, allowed)
    Accessing hidden method Lsun/misc/Cleaner;->clean()V (greylist,core-platform-api, reflection, allowed)
W/cenemax3dplaye: Accessing hidden method Lsun/nio/ch/DirectBuffer;->attachment()Ljava/lang/Object; (blacklist, reflection, denied)
W/cenemax3dplaye: Accessing hidden field Ljava/nio/ByteBufferAsFloatBuffer;->bb:Ljava/nio/ByteBuffer; (blacklist, reflection, denied)
    Accessing hidden field Ljava/nio/ByteBufferAsIntBuffer;->bb:Ljava/nio/ByteBuffer; (blacklist, reflection, denied)
    Accessing hidden field Ljava/nio/ByteBufferAsDoubleBuffer;->bb:Ljava/nio/ByteBuffer; (blacklist, reflection, denied)
    Accessing hidden field Ljava/nio/ByteBufferAsShortBuffer;->bb:Ljava/nio/ByteBuffer; (blacklist, reflection, denied)
W/cenemax3dplaye: Accessing hidden field Ljava/nio/ByteBufferAsLongBuffer;->bb:Ljava/nio/ByteBuffer; (blacklist, reflection, denied)
    Accessing hidden field Ljava/nio/ByteBufferAsCharBuffer;->bb:Ljava/nio/ByteBuffer; (blacklist, reflection, denied)
I/cenemax3dplaye: Background concurrent copying GC freed 2356(218KB) AllocSpace objects, 1(20KB) LOS objects, 49% free, 1698KB/3396KB, paused 444us total 143.135ms
W/cenemax3dplaye: Verification of void com.jme3.renderer.opengl.GLRenderer.renderMeshDefault(com.jme3.scene.Mesh, int, int, com.jme3.scene.VertexBuffer[]) took 117.921ms
W/cenemax3dplaye: Accessing hidden field Ljava/nio/Buffer;->position:I (greylist, JNI, allowed)
    Accessing hidden field Ljava/nio/Buffer;->limit:I (greylist, JNI, allowed)
W/cenemax3dplaye: Accessing hidden field Ljava/nio/Buffer;->_elementSizeShift:I (greylist, JNI, allowed)
    Accessing hidden field Ljava/nio/Buffer;->address:J (greylist, JNI, allowed)
E/emuglGLESv2_enc: device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetIntegerv:829 GL error 0x500
I/com.jme3.renderer.opengl.GLRenderer: INFO OpenGL Renderer Information
     * Vendor: Google (Google Inc.)
     * Renderer: Android Emulator OpenGL ES Translator (Google SwiftShader)
     * OpenGL Version: OpenGL ES 2.0 (OpenGL ES 3.0 SwiftShader 4.0.0.1)
     * GLSL Version: OpenGL ES GLSL ES 1.0.17
     * Profile: Compatibility
W/com.jme3.asset.AssetConfig: WARNING Cannot find loader com.jme3.cursors.plugins.CursorLoader
I/OpenGLRenderer: Davey! duration=852ms; Flags=1, IntendedVsync=2256716724156, Vsync=2256750057488, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=2256750726900, AnimationStart=2256750852800, PerformTraversalsStart=2256750921200, DrawStart=2256989264400, SyncQueued=2257005264600, SyncStart=2257007802900, IssueDrawCommandsStart=2257011275700, SwapBuffers=2257459045000, FrameCompleted=2257571317800, DequeueBufferDuration=40733000, QueueBufferDuration=246000, 
I/Choreographer: Skipped 50 frames!  The application may be doing too much work on its main thread.
W/com.jme3.asset.AssetConfig: WARNING Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
I/OpenGLRenderer: Davey! duration=938ms; Flags=1, IntendedVsync=2256786752253, Vsync=2257620085553, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=2257629408000, AnimationStart=2257629537500, PerformTraversalsStart=2257629606700, DrawStart=2257655940300, SyncQueued=2257660592700, SyncStart=2257660948700, IssueDrawCommandsStart=2257660998300, SwapBuffers=2257662756700, FrameCompleted=2257725184700, DequeueBufferDuration=24707000, QueueBufferDuration=11565000, 
D/: PlayerBase::PlayerBase()
D/: TrackPlayerBase::TrackPlayerBase()
I/libOpenSLES: Emulating old channel mask behavior (ignoring positional mask 0x3, using default mask 0x3 based on channel count of 2)
I/AudioTrack: createTrack_l(996278272): AUDIO_OUTPUT_FLAG_FAST successful; frameCount 0 -> 1322
I/com.jme3.audio.openal.ALAudioRenderer: INFO Audio Renderer Information
     * Device: OpenAL Soft
     * Vendor: OpenAL Community
     * Renderer: OpenAL Soft
     * Version: 1.1 ALSOFT 1.16.0
     * Supported channels: 64
     * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFTX_device_clock ALC_SOFTX_HRTF ALC_SOFT_loopback ALC_SOFTX_midi_interface ALC_SOFT_pause_device
     * AL extensions: AL_EXT_ALAW AL_EXT_BFORMAT AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_BFORMAT AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_block_alignment AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFT_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_MSADPCM AL_SOFT_source_latency AL_SOFT_source_length
I/com.jme3.audio.openal.ALAudioRenderer: INFO Audio effect extension version: 1.0
I/com.jme3.audio.openal.ALAudioRenderer: INFO Audio max auxiliary sends: 4
E/AndroidRuntime: FATAL EXCEPTION: GLThread 529
    Process: com.abware.scenemax3dplayer, PID: 8916
    java.lang.IllegalStateException: Framebuffer has erronous attachment.
        at com.jme3.renderer.opengl.GLRenderer.checkFrameBufferError(GLRenderer.java:1704)
        at com.jme3.renderer.opengl.GLRenderer.updateFrameBuffer(GLRenderer.java:1877)
        at com.jme3.renderer.opengl.GLRenderer.setFrameBuffer(GLRenderer.java:2018)
        at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1082)
        at com.jme3.renderer.RenderManager.render(RenderManager.java:1158)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:272)
        at com.jme3.app.AndroidHarnessFragment.update(AndroidHarnessFragment.java:577)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:348)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
E/com.jme3.app.AndroidHarnessFragment: SEVERE Exception thrown in Thread[GLThread 529,5,main]
    java.lang.IllegalStateException: Framebuffer has erronous attachment.
        at com.jme3.renderer.opengl.GLRenderer.checkFrameBufferError(GLRenderer.java:1704)
        at com.jme3.renderer.opengl.GLRenderer.updateFrameBuffer(GLRenderer.java:1877)
        at com.jme3.renderer.opengl.GLRenderer.setFrameBuffer(GLRenderer.java:2018)
        at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1082)
        at com.jme3.renderer.RenderManager.render(RenderManager.java:1158)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:272)
        at com.jme3.app.AndroidHarnessFragment.update(AndroidHarnessFragment.java:577)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:348)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
D/EGL_emulation: eglMakeCurrent: 0xcc00a600: ver 2 0 (tinfo 0xe2f4f6e0)
D/EGL_emulation: eglMakeCurrent: 0xcc00a600: ver 2 0 (tinfo 0xe2f4f6e0)
I/cenemax3dplaye: Background young concurrent copying GC freed 33409(1434KB) AllocSpace objects, 2(40KB) LOS objects, 36% free, 2677KB/4222KB, paused 563us total 222.204ms
D/EGL_emulation: eglMakeCurrent: 0xcc00a600: ver 2 0 (tinfo 0xe2f4f6e0)
1 Like

Here’s a fork of jme-ttf that doesn’t depend on jme3-desktop:

and here’s the latest release:

repositories {
    mavenCentral()
}
dependencies {
    implementation 'com.github.stephengold:jme-ttf:2.2.3'
}

and here’s a release of MaVehicles that uses jme-ttf v2.2.3:

repositories {
    mavenCentral()
}
dependencies {
    implementation 'com.github.stephengold:MaVehicles:0.6.1+for33'
}
4 Likes

AMAZING Stephen!! I can’t wait seeing Jme-Vehicles running on Android devices :slight_smile: Thanks a lot!

3 Likes

Yeh, OGLES 3.2, 3.0 works fine, but i haven’t tried OGLES 2.0 with GLSL version 1, what kind of emulator are you testing on ? , Avoid genymotion & non standard emulators because at most times, they got weird gpu setup…

seems there’s a restriction to access gpu of this emulator

Android 2.2 ? you are running on GingerBread don’t you ?

From this message, i can tell that the app is rendered successfully, but what happens after that causes this exception may be due to the driver shaders cannot update the frame buffer…

I think it’s better to search for a device that runs on OGLES3.0 or later as an initial setup…also it supports shaders better on the long run including PBR

If you are at the official android avd, go to the emulator driver settings & try to change the OGLES version to 3.0, after changing the android version to above 4.3

Please report if you still having problems…

NB:

* OpenGL ES 3.0 - This API specification is supported by Android 4.3 (API level 18) and higher.

which states that almost all physical devices supports OGLES3.0
1 Like