[SOLVED] Lemur GUI packaging error in gradle

I am getting error while building apk with gradle 7.6.
I’m using lemur and lemur proto.
Error-

Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
   > 2 files found with path 'com/simsilica/lemur/style/base/glass-styles.groovy' from inputs:
      - /.gradle/caches/modules-2/files-2.1/com.simsilica/lemur-proto/1.13.0/9163fc6865f204de84baac90b57820df86d5fe95/lemur-proto-1.13.0.jar
      - /.gradle/caches/modules-2/files-2.1/com.simsilica/lemur/1.16.0/8e4af305c8c00dde11db8d76be8debd5ee751c09/lemur-1.16.0.jar
   

Are you trying to build an android application with lemur-proto ?

Yes @Pavl_G

You cannot have a duplicate of folders inside your Android APK, they won’t merge, you need to create a delete Gradle task to delete one folder or a move task to merge their contents manually and call it before mergeDebug task.

I don’t have or created any folder. I just implemented it by

implementation 'com.simsilica:lemur:1.16.0'
implementation 'com.simsilica:lemur-proto:1.13.0'

Any also, what is the difference between lemur-proto and lemur?

Android doesn’t like the way lemur allows each library to have additions to the same style just by including the same style file. Android sees this as duplicate resources.

So on Android you have to exclude these files (and lose the default glass styling) and either create your own style or hand-merge the files together into your own glass style.

1 Like

Lemur has the core GUI. Lemur-proto has some add on GUI elements that are eventually going to be moved into core.

Yeah i deleted that glass style from lemur proto.

Ohhh

If you use the glass style then ListBox, Selector, Spinner, and maybe some others will not be styled properly if you remove the style file from Lemur-proto.

I copied classes from lemur-proto**.jar to lemur**.jar and this problem is solved.

And i haven’t loss glass style.

If you didn’t merge the files then you won’t have glass styling for the classes I said… ListBox especially will look strange.

Where the classes lived had nothing to do with it.

Are you able to load the glass style on Android?

glass-style is written in Groovy script and will be compiled at runtime. Afaik Android does not support runtime compilation of groovy scripts so you need to precompile them or rewrite them in pure java code.
(I have precompiled them, let me know if you need the jar, but have not tested it on Android yet;)

Edit:

Oh nice, i want that jar file.

You can get it here: https://drive.google.com/file/d/1ntrYGxPol5tZvswEr9Mqe4WuHFSYcmIv/view?usp=sharing

And for loading it, instead of calling BaseStyles.loadGlassStyle(); use the below code:

        GuiGlobals globals = GuiGlobals.getInstance();
        Binding bindings = new Binding(Map.of(
                "gui", globals,
                "styles", globals.getStyles()));
        GlassStyle glassStyle = new GlassStyle(bindings);
        glassStyle.run();

I have not used it on Android, please try it and let me know if it works.

Also, note that you still need to add a dependency to groovy jar.

1 Like