混淆的JavaFX JAR中的FXML找不到Controller类

时间:2012-12-28 13:06:48

标签: deployment ant javafx-2 obfuscation fxml

我使用Proguard 4.8混淆了我的javafx应用程序jar,而混淆的jar正在显示jar中缺少的一些类。缺少的类是FXML的所有控制器类。在build.xml中使用额外的两个实用程序jar混淆应用程序JAR的这一步有什么问题?

<target name="Ofuscating" depends="CreatingJars" >
    <taskdef resource="proguard/ant/task.properties" classpath="${WorkingFolder}/proguard.jar" />
    <proguard>
        -dontusemixedcaseclassnames
        -printmapping proguard.map
        -dontshrink
        -dontoptimize
        -dontskipnonpubliclibraryclasses
        -dontskipnonpubliclibraryclassmembers
        <!--flattenpackagehierarchy ''-->
        -libraryjars "${java.home}/lib/rt.jar"
        -libraryjars "${java.home}/lib/javaws.jar"
        -libraryjars "${env.JAVA_HOME}/lib/ant-javafx.jar"
        -libraryjars "${env.JREFX_HOME}/lib/jfxrt.jar"          
        -libraryjars ${WorkingFolder}/libs/BareBonesBrowserLaunch.jar
        :
        :
        -libraryjars ${WorkingFolder}/CustomJars/Lib.jar 
        -injars ${WorkingFolder}/${app.name}.jar
        -injars ${WorkingFolder}/CustomJars/Verifier.jar(!META-INF/MANIFEST.MF)
        -injars ${WorkingFolder}/CustomJars/Utility.jar(!META-INF/MANIFEST.MF)
        -outjars ${WorkingFolder}/Obfuscated.jar
        -ignorewarnings
        -keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod
        -adaptresourcefilecontents **.fxml,**.properties,META-INF/MANIFEST.MF,images/*.jar,publicCerts.store,production.version
        -keepclassmembernames class * {
            @javafx.fxml.FXML *;
        } 
        -keepclasseswithmembers public class com.javafx.main.Main, com.product.main.EntryFX, net.license.LicenseEntryPoint {
            public *; public static *;
        }
        -keep class * extends org.xml.sax.helpers.DefaultHandler
        -keepclassmembers class * extends org.xml.sax.helpers.DefaultHandler {
            private *;
                public *;
        }
    </proguard>
</target>

1 个答案:

答案 0 :(得分:4)

.fxml个文件包含具有控制器类名称的字符串。

<Scene width="550" height="550"
    fx:controller="fxmltableview.FXMLTableViewController" 
    xmlns:fx="http://javafx.com/fxml">

您需要将控制器排除在混淆之外,或者找出他们的新名称,并在混淆的jar中更新.fxml个文件。