使用proguard进行模糊处理后无法加载FXML文件

时间:2018-06-11 07:22:10

标签: javafx proguard obfuscation fxmlloader

运行混淆的jar后出现以下错误:

  

引起:java.io.UncheckedIOException:加载FXML时出错:/fxml/main.fxml

     

引起:javafx.fxml.LoadException:   未知路径

但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 *;}

1 个答案:

答案 0 :(得分:0)

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

  

问题是FXML无法导入不以大写字母开头的类。因此,必须提供ProGuard用于混淆的可用名称列表。

更多详情请见:https://stackoverflow.com/a/29374932/2627659