I am obfuscating my javafx application jar using Proguard 4.8 and obfuscated jar is showing some classes missing into the jar. The missing classes are all the controller classes of FXML. What’s wrong with this step in build.xml that Obfuscates the application JAR with additional two utilities 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>
.fxmlfiles have strings with exact names of the controller class.You need to either exclude controllers from obfuscating or find out their new names and update
.fxmlfiles in obfuscated jar.