Android Modern Examples

I am currently trying to solve this issue :

So, this is what i have reached so far :

I still don’t know if this is enough to solve this issue, let me know what would you like to see as an example or a tutorial on android development with jMonkeyEngine and i will add it to this repo ?

If you are currently porting your game to android, let me know if there is a use-case you want to try ?

hints :
Would a Scala and/or Groovy examples be useful ?
Would a lemur example be useful ?
Would a Minie example be useful ?
Would a shader workflow example be useful ?
Or they are more like engine oriented and just gradle ?

EDIT :
This issue is also a similar target (although quite invalid for me, but will be resolved when simple examples are provided for sure) :

3 Likes

Not for me exactly, but the template I use for https://start.jmonkeyengine.org/ has trouble with lemur on android (if both lemur and lemur-proto are included android complains when it tries to merge everything) so if you have a working lemur android example that would be helpful for me to use to update the template

1 Like

I have started the process of porting Advanced Vehicles to android recently, and yes some components of Lemur was buggy with android and i cannot remember which part (and mostly was incompatible dependencies), but as of Lemur basic setup, it was working !

As of this, i will start building some examples for lemur and will include them on different modules on this repository.

Okay, what else ?

That’s because guava-19 is a duplicate, you can exclude it from the proto module.

Execution failed for task ':hellolemur:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-19.0 (com.google.guava:guava:19.0) and jetified-listenablefuture-1.0 (com.google.guava:listenablefuture:1.0)
     
     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

I ran an android test today, lemur works on android, but lemur styles don’t work, due to missing javax.script.ScriptEngineManager from android system :

This exception is raised when trying to use BaseStyles.loadGlassStyle(); :

E/AndroidRuntime: FATAL EXCEPTION: GLThread 7236
    Process: com.jme3.hellojmesurfaceview, PID: 6177
    java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/script/ScriptEngineManager;
        at com.simsilica.lemur.style.StyleLoader.<init>(StyleLoader.java:72)
        at com.simsilica.lemur.style.StyleLoader.<init>(StyleLoader.java:62)
        at com.simsilica.lemur.style.BaseStyles.loadStyleResources(BaseStyles.java:72)
        at com.simsilica.lemur.style.BaseStyles.loadGlassStyle(BaseStyles.java:62)
        at com.jme3.hellojmesurfaceview.MyGame.simpleInitApp(MyGame.java:48)
        at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
        at com.jme3.view.surfaceview.JmeSurfaceView.initialize(JmeSurfaceView.java:294)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:344)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.script.ScriptEngineManager" on path: DexPathList[[dex file "/data/data/com.jme3.hellojmesurfaceview/code_cache/.overlay/base.apk/classes2.dex", zip file "/data/app/~~c01C2qvFAtlfaA5P1zTbkg==/com.jme3.hellojmesurfaceview-YWYnzg8owki_m9SpjFZMWA==/base.apk"],nativeLibraryDirectories=[/data/app/~~c01C2qvFAtlfaA5P1zTbkg==/com.jme3.hellojmesurfaceview-YWYnzg8owki_m9SpjFZMWA==/lib/arm64, /data/app/~~c01C2qvFAtlfaA5P1zTbkg==/com.jme3.hellojmesurfaceview-YWYnzg8owki_m9SpjFZMWA==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64, /system/product/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.simsilica.lemur.style.StyleLoader.<init>(StyleLoader.java:72) 
        at com.simsilica.lemur.style.StyleLoader.<init>(StyleLoader.java:62) 
        at com.simsilica.lemur.style.BaseStyles.loadStyleResources(BaseStyles.java:72) 
        at com.simsilica.lemur.style.BaseStyles.loadGlassStyle(BaseStyles.java:62) 
        at com.jme3.hellojmesurfaceview.MyGame.simpleInitApp(MyGame.java:48) 
        at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240) 
        at com.jme3.view.surfaceview.JmeSurfaceView.initialize(JmeSurfaceView.java:294) 
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:344) 
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573) 
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272) 

AFAIK Android does not support runtime compilation of groovy scripts, so I think you must precompile groovy script or rewrite the style in pure java.

Seem there is one for glass style:

Edit:
Note I think this is based on an older version of style file, missing the spinner layout,…

2 Likes

I ran a precompiled groovy and scala before on android, don’t know if android can compile them, but gradle tasks can (you just need to add a compiler call before android tasks) !

Android doesn’t have javax.styles.* package, so have you tested this on android ?

In the gist file I linked there is no javax.styles.*
I have not tested this class, it was created by jayfella.

1 Like

They are used by lemur on StyleLoader class, and they create problems with android ClassNotFoundExecption :

I am sorry it’s javax.script not style :grin:

Also there is a gradle pluging for compiling groovy for Android but it is no maintained.

1 Like

Thanks for sharing, this may be helpful, i was compiling groovy externally with a bash script and then packaging it as a jar and including inside lib folder.

import com.simsilica.lemur.style.Styles;

I am not sure if this uses StyleLoader too, but in general doing :

BaseStyles.loadGlassStyle();

raises a ClassNotFoundException on javax.scripts.ScriptEngineManager

Don’t know if we can ship it manually ?

I think for using the gist file I linked above you do not need to use StyleLoader, just instantiate LemurGuiStyle class and it should apply the style but as said I have never used it before.

1 Like

Alright, this works fine, you are right, it doesn’t call for javax.script.ScriptManager

Will lemur provides some documentation notes for this ?

EDIT :
But, i think you can omit this heart burn and use jMonkeyEngine textures directly with a QuadBackgroundComponent.

There is a wiki page:

1 Like

Thank you !

If you know a fix for lemur/lemur-proto duplicate res files please let me know, after that we will have a working example for lemur-proto together besides lemur on android :slight_smile: .

1 Like

Unfortunately, I have no idea about this issue.

1 Like

Note: nothing requires you to use the groovy styles or default styles. You are free to hand-code styles in Java. No groovy required. Just don’t include the style resources and don’t load the glass style. Done.

1 Like

Yeah, got it.

I am still searching for this.

Others have definitely used Lemur on android before and so must have found a way to exclude files from the apk build or whatever.

…in gradle it should be trivial to exclude things, I would guess.