使用混淆器混淆后无法加载 FXML 文件

FXML file can't load after obfuscation with proguard

我在 运行 混淆 jar 后得到以下错误:

Caused by: java.io.UncheckedIOException: Error loading FXML: /fxml/main.fxml

Caused by: javafx.fxml.LoadException: unknown path

但是 FXML 文件存在于指定路径上。

我的 ProGuard 配置文件包含以下规则:

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod,javafx.fxml.FXML

-adaptresourcefilenames **.fxml,**.png,**.css,**.pdf,**.ttf,**.otf,**.txt
-adaptresourcefilecontents **.png,**.css,**.pdf,**.ttf,**.otf,**.txt
-adaptresourcefilecontents **.fxml,**.properties,META-INF/MANIFEST.MF
-adaptclassstrings

-keepclassmembernames class * {@FXML *;}

这个问题是重复的;这是这个问题的答案:

The problem is that FXML cannot import classes that do not start with an upper case letter. Therefore one has to provide an own list of available names that ProGuard uses for obfuscating.

详情请见: