OpenGL ES 3.0 and newer on android

Good job, thanks :slightly_smiling_face:

Thank you greatly @joliver82 for your hard work and contribution to the android side of jME.
I am a huge Android fan and have a few apps out on the play store.

I however have one question to you, what is your development cycle for android apps?
In other words how do you develop? Do you use jMonkeyPlatform, gradle or android studio?

Any feedback would be appreciated.

@joliver82 have you also tried PBRLighting in android?

Sadly my development cycle for jme3 based android apps is unconfortable as hell. :confused:

As I started with really old versions of jme3 (alpha2) and my project was not defined only for android, I’m using jmonkey sdk + a slightly modified android studio project from GitHub - noncom/jme-android-example

I have NBandroid installed and enabled android build so the mobile path is created. I used that as base for the project I linked (adding symbolic links for libraries, code, assets and so).

The cycle is like:

  • Work on the game itself in jmonkey
  • Make a full build, so although android compilation fails it generates all libs, assets and so in the destination folder used by the android studio project
  • Add android specific functionality in android studio and generate the apk

Probably there are plenty of better options, like just using the linked project or any other similar as starting point for your development but if using android studio or any other IDE you’ll loose the functionality jmonkey SDK has…

If anyone knows a better approach I’ll be happy to hear from you :wink:

1 Like

Not still. I’m adding stuff day by day and now I’m focused on getting shadows working 100% which is taking me more time than expected. It’s a complex topic for me :sweat_smile:

1 Like

Not an android developer, but hopefully this might be helpful, I was able to create my ever first android hello world app in JME easily using this Gradle template.


After build it generates two apks, one inside debug directory an one in the release directory. The debug one can be easily installed on smartphone, but I guess the release one needs to be signed with Java Keystore which unfortunately I couldn’t figure it how.

Thanks @joliver82 for sharing.

Well my approach is a bit different.
I am also using the jMonkeyEngine SDK except the difference is I actually build android using the old sdk ant build as documented in the wiki.

I have to make my own build of the SDK because in order for the NBAndroid plugin to work in the jME sdk you need version 8.1 of netbeans.

After that I also need an old version of Android SDK manager but I install the latest versions of android platform tools and sdk tools.
I use this version:

Then it is a matter of setting up my custom jME SDK to point to that android sdk.

So far this works for me very good and has been for years now.

Hope it helps a bit if you want to go into that route.

I can’t wait to see the shadow work you are doing.
If you want I can also test the code by creating some sample test projects for the test cases.

I could have used the gradle scripts from the android studio project I used as reference instead of fully install android studio but I think for my use case it’s better to have it, specially if you develop other android apps not jme based and/or to be able to debug android apps more or less easily.

I miss the good old times when eclipse was de default IDE for android… :stuck_out_tongue:

On the other hand, it’s a good manual :wink: I would have loved to have it when I started trying to compile my app for android with multidex (that’s the reason I moved to android-studio and gradle)

It’s a good aproach. I didn’t realize the issue with nbandroid was that newest jmonkey sdk is based on a newer netbeans release. Anyway, I would prefer to have NBandroid updated but it seems that the developer stoped mantaining it :frowning:

There’s a project called nbandroid-v2 (GitHub - NBANDROIDTEAM/NBANDROID-V2: Netbeans Android support plugin) that I’ve not tried still but seems to be less stable / finished than original nbandroid was in its time. Have any of you had time to check it?

Hi, hopefully you can help me with this…

I’m calling some methods of the GLES31 class ( but I cannot get it to compile:

       GLES31.glGetMultisamplefv(pname, index, val);
 symbol:   variable GLES31
 location: class AndroidGL

The build.gradle is the default of jme3:

if (!hasProperty('mainClass')) {
ext.mainClass = ''

dependencies {
    compile project(':jme3-core')
    compile project(':jme3-plugins')
    compileOnly 'android:android'

The "compileOnly ‘android:android’ is supposed to get the android dependencies but it’s failing for this class.

This class was included in API level 21, so maybe I should add something to the gradle file that I’m not aware of…

Thanks :wink:

There are quite a few more gradle settings to configure. Not sure if you’re aware since you didn’t specify them in your post.

There’s a target and min version, etc.

1 Like

Thanks for your comment @jayfella but it’s the whole build.gradle file. What I’m trying to compile is the jme3-android library, not an application, so all other settings related to android are not accesible :

  • What went wrong:
    A problem occurred evaluating project ‘:jme3-android’.
    > Could not find method android() for arguments [build_akah3vddwdy7zw5ofwuoggqvr$_run_closure1@a96f79e] on project ‘:jme3-android’ of type org.gradle.api.Project.

I could try to change it from regular java to android library (apply plugin: ‘’) and setting all stuff there but I think there should be other method.

OK, I found out… it’s the library at /jmonkeyengine/lib/android.jar the one having the android classes. Just updating it to a newer version including GLES31 and GLES32 will suffice


Sorry, I missed the part of your comment about properly signing the apk. I use a small shell script as follows:

cp android-studio-project/app/release/app-release.apk app.apk 
jarsigner -verbose -keystore ./keystore_file -storepass store_password -keypass key_password -sigalg SHA1withRSA -digestalg SHA1 app.apk key_name
rm app-align.apk
zipalign 4 app.apk app-align.apk

basically it’s removing bad signature information, sign it again and align the zip :wink:

1 Like

Hi there!

I’m working trying to get shadows to android gles3 but I’m facing a weird issue, depending on the device I’m getting the shadows rendered or just overriding the scene in grey:


And I don’t understand why. The depth map is properly generated in all devices tested and I’ve simplified the rendering by creating a new material based on the unshaded.j3md but instead of using the default PostShadow.frag I’m using a simplified version that’s just rendering depth over the scene:

#import "Common/ShaderLib/GLSLCompat.glsllib"
#import "Common/ShaderLib/Shadows.glsllib"

varying vec4 projCoord0;
varying vec4 projCoord1;
varying vec4 projCoord2;
varying vec4 projCoord3;
    varying float nDotL;

    varying vec4 projCoord4;
    varying vec4 projCoord5;
    uniform vec3 m_LightPos;
    varying vec4 worldPos;
    #ifndef PSSM        
        varying float lightDot;

void main(){   

        if(nDotL > 0.0){

            shadow = 1.0f;
            shadow = texture(m_ShadowMap0,;

    shadow = shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity);
    gl_FragColor = vec4(shadow, shadow, shadow, 1.0);


Everything is defined to use GLSL300 ( #version 300 es) added to the header dynamically to the shader by new jme code I added.

I hope there’s any shader expert over here to help with this :wink:

It’s been one week focused on shadows and finally I got them working rendering on both GLES2.0 and GLES3.0:


I’ve tested it on all my devices with good results. It would be nice if you have time to test it and give me some feedback :wink:

Now I’m into PBR ligthing which at least the shaders compile properly now (but don’t render any effect)


Great job @joliver82

I hope you have success with PBR too. :slightly_smiling_face:

btw, it is recommended to use to upload your screenshots, then you won’t have a limit on image size.

Good day @joliver82,

I am busy testing you code but when I enable the DirectionalLightShadowFilter I get the following error. As a side note I am using the “Common/MatDefs/Light/Lighting.j3md” material on a box.

Error on android:

06-12 11:48:29.375  9092  9143 E SEVERE Exception thrown in Thread[GLThread 7707,5,main]
06-12 11:48:29.375  9092  9143 E com.jme3.renderer.RendererException: compile error in: ShaderSource[name=Common/MatDefs/Shadow/PostShadowFilter.frag, defines, type=Fragment, language=GLSL100]
06-12 11:48:29.375  9092  9143 E 0:9: P0003: Warning: Extension 'GL_ARB_gpu_shader5' not supported
06-12 11:48:29.375  9092  9143 E 0:119: L0003: Keyword 'sampler2DShadow' is reserved
06-12 11:48:29.375  9092  9143 E 
06-12 11:48:29.375  9092  9143 E 	at com.jme3.renderer.opengl.GLRenderer.updateShaderSourceData(
06-12 11:48:29.375  9092  9143 E 	at com.jme3.renderer.opengl.GLRenderer.updateShaderData(
06-12 11:48:29.375  9092  9143 E 	at com.jme3.renderer.opengl.GLRenderer.setShader(
06-12 11:48:29.375  9092  9143 E 	at com.jme3.material.logic.DefaultTechniqueDefLogic.render(
06-12 11:48:29.375  9092  9143 E 	at com.jme3.material.Technique.render(
06-12 11:48:29.375  9092  9143 E 	at com.jme3.material.Material.render(
06-12 11:48:29.375  9092  9143 E 	at com.jme3.renderer.RenderManager.renderGeometry(
06-12 11:48:29.375  9092  9143 E 	at
06-12 11:48:29.375  9092  9143 E 	at
06-12 11:48:29.375  9092  9143 E 	at
06-12 11:48:29.375  9092  9143 E 	at com.jme3.renderer.RenderManager.renderViewPort(
06-12 11:48:29.375  9092  9143 E 	at com.jme3.renderer.RenderManager.render(
06-12 11:48:29.375  9092  9143 E 	at
06-12 11:48:29.375  9092  9143 E 	at
06-12 11:48:29.375  9092  9143 E 	at
06-12 11:48:29.375  9092  9143 E 	at android.opengl.GLSurfaceView$GLThread.guardedRun(
06-12 11:48:29.375  9092  9143 E 	at android.opengl.GLSurfaceView$

Thanks for the feedback. I forgot to specify that I was working with shadow rederers not filters :confused: I’ll have a look at filters later also and get back to you :wink:

Just in case it was relevant, could you tell me the device you’re using?