gluonhq / gluonfx-gradle-plugin

Plugin that simplifies using Gluon Client for Java/JavaFX gradle projects
BSD 3-Clause "New" or "Revised" License
100 stars 21 forks source link

Mac OS: Image compiles and runs, but no display. #86

Closed xcporter closed 4 years ago

xcporter commented 4 years ago

Hello!

I've using version 1.31 of the plugin with JavaFx 11.

When I compile and run a native image, the executable runs, but no window is displayed. In the command line I get the following exceptions:

java.lang.RuntimeException: Unable to construct Application instance: [application class name] Caused by: java.lang.NoSuchMethodException: [application class name].()

One possible reason might have to do with the fact that it's written in Kotlin with TornadoFx.

I've tried modifying the launch method to use more java-like conventions, but to no avail.

Any idea what might be causing this?

jperedadnr commented 4 years ago

See related issue: https://github.com/gluonhq/substrate/issues/572

You can see that you have to add the classes from the main application class to the reflection list.

xcporter commented 4 years ago

Thank you!

How does this configuration look in gradle?

At this point, I'm trying to add it to the gluonPlugin as a list of strings, but now it won't compile

gluonClient {
       reflectionList = [
            "org.test.AdminApp",
            "org.test.MainView",
            "org.test.AdminStyle"
           ...
    ]
}
jperedadnr commented 4 years ago

That should work. What error do you get?

xcporter commented 4 years ago

After a little more checking I just had some references wrong, so the reflection list is working.

I followed a few different error paths and ended up resolving a few more "unsupported feature" errors by rearranging code.

I can get a basic app to display nicely, but there are a few remaining hangups:

--it doesn't seem to pick up the TornadoFX stylesheet class, but no big deal since inline style is working just fine.

--it can't seem to find the JavaFx resources necessary to instantiate a media player (java.lang.NoClassDefFoundError: javafx/scene/media/Media)

I'm including the media module with the openjfx gradle plugin like this:

javafx {
    version = "11"
    modules = [ 'javafx.controls', 'javafx.media', 'javafx.fxml']
}

Should I be including some kind of additional arguments for native image regarding javafx.media?

jperedadnr commented 4 years ago

What extension is your style class, css? Media is not supported yet.

xcporter commented 4 years ago

The css is a tornadofx construct--no extension on the file, but the css is stored in a class like this:

class Style : Stylesheet() {
    companion object {
        //css rules declared here and delegated, then defined in the init block
    }
}

Then it's compiled with type safety. Though, it doesn't seem to be working with inline style either now that I look.

For some reason I thought I could get away with javaFX media player if the target was desktop--not sure where I got that idea actually. I suppose I'll look into the charm-down plugin, or libVLC or something.

If it works with the css migrated to actual css files, I might just go that route. Reformatting a few files is a small price to pay for a nice binary.

Thank you for all your amazing help!

jperedadnr commented 4 years ago

If the css class is used reflectively, try adding it to the reflectionList as well. That might work. Migrated to .css should work too, of course.