You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用JavaFX19的GluonMobile应用启动失败问题求助

JavaFX 19新增API在Gluon GraalVM编译的Android应用中启动失败

依赖配置

<maven-compiler-plugin-version>3.10.1</maven-compiler-plugin-version>
<maven-surefire-plugin-version>3.0.0-M6</maven-surefire-plugin-version>
<javafx-maven-plugin-version>0.0.8</javafx-maven-plugin-version>
<gluonfx-maven-plugin-version>1.0.14</gluonfx-maven-plugin-version>

<java-version>17</java-version>
<javafx-version>19</javafx-version>
<charm-version>6.1.0</charm-version>
<attach-version>4.0.15</attach-version>

问题场景

使用上述依赖结合模板POM与graalvm-svm-java17-linux-gluon-22.1.0.1-Final编译Android应用,代码中使用了JavaFX19新增的map方法,示例代码如下:

public class ConsoleView extends View {

    ListView<String> console = new ListView<>();

    public ConsoleView() {
        console.setCellFactory(listView -> {
            var cell = new ListCell<String>() {

                {
                    textProperty().bind(itemProperty());
                    textFillProperty().bind(textProperty().map(text -> {
                        if (text.contains("RED")) {
                            return Color.RED;
                        } else if (text.contains("ORANGE")) {
                            return Color.ORANGE;
                        }
                        return Color.BLACK;
                    }));
                }
            };
            return cell;
        });
        setCenter(console);
        console.getItems().add("RED");
        console.getItems().add("BLUE");
        console.getItems().add("GREEN");
        console.getItems().add("ORANGE");
    }
}

异常信息

代码编译构建正常,桌面IDE运行无问题,但Android设备启动时抛出如下异常:

D/GraalCompiled( 4642): Exception in thread "JavaFX Application Thread" java.lang.NoSuchMethodError: javafx.beans.property.StringProperty.map(java.util.function.Function)
D/GraalCompiled( 4642):         at com.my.view.ConsoleView$1.<init>(ConsoleView.java:29)
D/GraalCompiled( 4642):         at com.my.view.ConsoleView.lambda$0(ConsoleView.java:25)
...

问题分析与疑问

javafx.beans.property.StringProperty.map是JavaFX19新增的方法。编译和构建阶段能正常找到该方法,但Android运行时出现方法缺失,推测是动态链接相关问题。

看到Gluon文档提到JavaFX版本已更新至19-ea+8,请问我需要更新相关组件还是等待官方更新?

内容的提问来源于stack exchange,提问作者user1803551

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 20:25:31