MultiView FXML Project on iOS using Gluon-mobile a

2019-07-22 18:54发布

问题:

Creating a completely new MultiView FXML Project and then adding the Java9 necessities in Gradle:

buildscript {
    repositories {
        jcenter()
        google()
        maven{
            url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
        }
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:2.0.5'
    }
}

...

sourceCompatibility = 1.8
targetCompatibility = 1.8

...

dependencies {
    compile 'com.gluonhq:charm:4.4.0-jdk9'
    androidRuntime 'com.gluonhq:charm:4.4.1'
    compile 'com.airhacks:afterburner.mfx:1.6.3'

    // Added because of javax.annotation.PostConstruct Java9 issues
    compile group: 'javax.xml.ws', name: 'jaxws-api', version: '2.2.6'    
}

leads to [SUB] Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Stage must be showing before making the Dialog visible.

full console log

The project runs as expected on Desktop and Android, but not on iOS simulator and device. I have tried many things, but since this error comes on newly created projects leads me to believe that it's something caused by the interplay of gluon-mobile and Java9.

Bonus: Changing only the jfxmobile-plugin to 2.0.18 fails even compiling with:

[15:08:15:141] com.gluonhq.higgs.Higgs: Still compiling... 8823 classes left.
[15:08:25:143] com.gluonhq.higgs.Higgs: Still compiling... 4152 classes left.
[15:08:34:389] com.gluonhq.higgs.Compiler: halfway done round 0 java.lang.StackOverflowError
at java.base/java.util.HashMap.putVal(HashMap.java:642)
at java.base/java.util.HashMap.put(HashMap.java:612)
at java.base/java.util.HashSet.add(HashSet.java:220)
at com.gluonhq.higgs.DependencyGraph.visitReachableNodes(DependencyGraph.java:170)

回答1:

These steps work for me:

  • Using Java 9, and NetBeans 9 (beta version) with Gluon IDE plugin 2.6.2, I've created a Gluon project (multi view with FXML). Of course, this will work with other IDEs as well.

  • I've checked that the gradle wrapper was using 4.3.1 (or superior).

  • I've modified the build.gradle file to use Gluon VM with jfxmobile 2.0.18:

build.gradle file:

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
        }
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:2.0.18'
    }
}

and updated the dependencies:

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile 'com.gluonhq:charm:4.4.0-jdk9'
    compile 'com.airhacks:afterburner.mfx:1.6.3'
    compile 'javax.annotation:javax.annotation-api:1.3.2'
    androidRuntime 'com.gluonhq:charm:4.4.1'
}
  • Then I just deployed the project to my iOS device without any issue.

Note that it may be convenient to clean your ~/.gvm cache, as it might contain classes from older versions that shouldn't be used anymore. Of course, you should also clean your project ./gradle and /build folders.