Android / jME questions: GUI

Hi everyone,

I am currently developing a small map editor for Android (mainly personal use, but I might Open-Source it).
I used aegroto’s template and BootMonkey, so I have the following project structure:

Root Folder
  - MainApplication
  - ...
  + Game
  | - Main (SimpleApplication)

For the map editor, I need to be able to declare several variables, like tile type, and I can do that through a GUI.
I like the Android GUI (standard android Views), so I would prefer to use that, like jME and swing work together. However, I can’t refer to any of my game classes from my android classes, and I can’t change the variables located in the game.

Another option I have is using one of jME’s GUIs, which include Lemur, Nifty, and t0neg0d’s GUI.
I don’t want to use Nifty and I don’t know how to use t0neg0d’s GUI, so my options are basically limited to Lemur and Android GUI.

That brings me to the questions:

  • Can I use the Android GUI and jME together?
  • If so, how?
  • Does Lemur have Android support?
  • If so, to what extend / what are the known bugs?

Yes, it should work fine. Even with multitouch, ie: you can drag two sliders at once with different fingers and stuff.

One of the other main Lemur contributors was one of JME’s android guys (though hasn’t been around much lately.)

I don’t know of any off the top of my head.

Sounds good.

Sounds even better.

I will probably use Lemur then.

I also solved my other problem: Android <-> jME communication.
For anyone that needs to use Android applications in their jme module project:
You can refer to your Application through the AndroidHarnessFragment#getJmeApplication(). The Application contains the AppStateManager, through which you can call any loaded AppState. For example, you can use Android libs to search for a file in the data folders, and then send the file through a function/buffer/queue in a state, that handles the rest, like writing to it.

I have encountered a problem:

When trying to add Lemur through Gradle using the following lines:

repositories {

dependencies {
    compile "com.simsilica:lemur:1.9.1"
    compile "com.simsilica:lemur-proto:1.8.1"

It will cause an error during gradle build: Duplicate files copied in APK com/simsilica/lemur/style/base/glass-styles.groovy

I guess both lemur and lemur proto have the same file?
How can I solve this?

I’m not sure. I’m hoping one of the Lemur users who uses Android might pipe in.

I sort of remember people having problems getting groovy to run on Android anyway so you might not be able to use the style language… in that case if there is some way to exclude those files then it might be one workaround. But a bit of a shame.

Also a shame if android doesn’t support the multiple files somehow. The Lemur style loader will combine them dynamically at runtime if it finds more than one. That way extensions can easily add the styles for the components that they add.

I kind of feel like there has to be a way to solve this, though.

So I ‘solved’ the problem this way:

android {
    packagingOptions {
    	exclude 'com/simsilica/lemur/style/base/glass-styles.groovy'

Which seems a very dirty way to do this. However, I don’t get any errors anymore.

I do have another problem:
when using the dependencies stated in my previous post, I don’t seem to be able to import com.simsilica.lemur.GuiGlobals or any other class. This is probably more of a gradle problem than an android one, but it might as well be the android spacing out.

For some reason, Gradle can build GuiGlobals without problem, but Eclipse can’t find it. That is a problem on my end, not of Lemur.

It turned I forgot to press on ‘Refresh Gradle Project’. :smile:

You cant use groovy on android. From experience. And the way you excluded the file is correct.

I mean, there must be some way to do it. A quick google seems to imply as much.

…finds lots of promising looking hits. Though most seem more than a year or two old so maybe things changed. ?

I tried fairly recently, around 3 mo ths ago. If memory serves, android doesnt contain some kind of loader that it needed. Ill see if i can find the project and the error.

Well, there is one when the app is left in background and you go to it again (ie: home button → open task manager → select background running game). All the UI messes up (it do it sometimes when opening the game too). There is a problem on some devices too that crash the apps when loading assets on startup (however, I didn’t have time to check this and make a “good” report).

About the first issue… there is no any log message that could help so I still thinking a way to debug it.

These don’t sound like Lemur specific issues. I mean, they could be… but nothing in your description indicates that.

Yep, and that’s why I didn’t file a bug report yet. However, lemur is the single thing that “breaks”. Just mentioning it here so the OP is aware of that possibility and if he finds a similar issue he’ll comments it back knowing he isn’t the only one.

What exactly breaks? I don’t remember. If there is another thread then feel free to link it.

I remember some issue with the GUI node getting drawn in reverse order or something. Is that the one? And things in the gui node don’t get badly sorted if Lemur is not initialized? (The thing is I sort of remember someone complaining about the stats view getting inverted in a similar way and I’m not sure lemur was involved in that case.)

Some investigation into what happens in the application life cycle when the app goes into the background.

But if I’m wrong in guessing what the issue is then none of that means anything.

There isn’t.

I’m not sure, I remember it felt like if the styles where just messed up with positions and sizes. When the app goes to background, I can see how the game rotates while fading (The game is vertical and it rotates to horizontal). Then, when reopening, all is messed up. Maybe it has something to do with that rotation.

I’ll see if I find a moment this afternoon to test it and perform some further checks.

Ok, I’ve been trying it now on the emulator and nothing breaks. O.o, it was the last time I tried it some days ago. That’s strange :S. Were there a lemur upgrade the last few weeks?.

1.10.1 was released like a month ago:

…but don’t you know what version you use?

xD not really, I have the + wildcard on the gradle file and the stage of that projects are just very early so I like to have them always with the latest versions, it forces me to adapt the code so when it is time to release I’m in the latest versions.

Maybe that version fixed the problem. Currently the problem is gone, I’ll inform once I know the why and if is really gone or if it is just not always.

Maybe. It could have been something else also.

I don’t see anything that looks related in the changelog:

…but I skimmed it quickly.

It seems to be working. Thanks for all the help in this thread. As of right now, i have not encountered a bug yet.

Note: without groovy you can still setup styles in code. It’s just more verbose… but for the most part the translation is straight-forward.

For example, from the glass style fie:

selector( "glass" ) {
    fontSize = 14
selector( "label", "glass" ) {
    insets = new Insets3f( 2, 2, 0, 2 );
    color = color(0.5, 0.75, 0.75, 0.85)     

Is the same as the following Java:

Styles styles = GuiGlobals.getInstance().getStyles();
Attributes attrs;

attrs = styles.getSelector("glass");
attrs.set("fontSize", 14);

attrs = styles.getSelector("label", "glass");
attrs.set("insets", new Insets3f(2, 2, 0, 2);
attrs.set("color", new ColorRGBA(0.5f, 0.75f, 0.75f, 0.85f);

…and so on.

1 Like