java - Obfuscating source code using proguard -
i want obfuscate source code using java obfuscators. used proguard suggested one. configured build.xml follow
<target name="-post-jar"> <property name="proguard.jar.path" value="d:/pro/proguard.jar" /> <taskdef resource="proguard/ant/task.properties" classpath="${proguard.jar.path}" /> <echo message="obfuscating ${dist.jar}..."/> <mkdir dir="${build.dir}/obfuscated"/> <proguard printmapping="${build.dir}/obfuscated/${application.title}.map" renamesourcefileattribute="sourcefile" ignorewarnings="true"> <injar file="${dist.jar}" /> <outjar file="${build.dir}/obfuscated/${application.title}.jar" /> <libraryjar path="${javac.classpath}" /> <libraryjar file="${java.home}/lib/rt.jar" /> <libraryjar file="${java.home}/lib/jce.jar" /> <keepattribute name="innerclasses" /> <keepattribute name="sourcefile" /> <keepattribute name="linenumbertable" /> <keepattribute name="deprecated" /> <keepattribute name="*annotation*" /> <keepattribute name="signature" /> <keepattribute name="exceptions" /> <keep access="public"> <field access="public protected" /> <method access="public protected" /> </keep> <keepclassmembernames access="public"> <method type ="java.lang.class" name ="class$" parameters="java.lang.string" /> <method type ="java.lang.class" name ="class$" parameters="java.lang.string,boolean" /> </keepclassmembernames> <keepclasseswithmembernames> <method access="native" /> </keepclasseswithmembernames> <keepclassmembers extends="java.lang.enum"> <method access="public static" type="**[]" name="values" parameters="" /> <method access="public static" type="**" name="valueof" parameters="java.lang.string" /> </keepclassmembers> <keepnames implements="java.io.serializable"/> <keepclassmembers implements="java.io.serializable"> <field access ="final" type ="long" name ="serialversionuid" /> <field access ="!static !transient" name ="**"/> <field access ="!private" name ="**"/> <method access ="!private" name ="**"/> <method access ="private" type ="void" name ="writeobject" parameters="java.io.objectoutputstream" /> <method access ="private" type ="void" name ="readobject" parameters="java.io.objectoutputstream" /> <method type ="java.lang.object" name ="writereplace" parameters="" /> <method type ="java.lang.object" name ="readresolve" parameters="" /> </keepclassmembers> </proguard> <copy file="${build.dir}/obfuscated/${application.title}.jar" tofile="${dist.jar}" overwrite="true"/> <delete dir="${build.dir}/obfuscated"/> </target>
but results in following error :
java.lang.unsupportedoperationexception: method must overridden in [proguard.optimize.peephole.classmerger] if ever called @ proguard.classfile.util.simplifiedvisitor.visitanyclass(simplifiedvisitor.java:47) @ proguard.classfile.util.simplifiedvisitor.visitlibraryclass(simplifiedvisitor.java:59) @ proguard.classfile.libraryclass.accept(libraryclass.java:301) @ proguard.classfile.programclass.subclassesaccept(programclass.java:433) @ proguard.optimize.peephole.verticalclassmerger.visitprogramclass(verticalclassmerger.java:83) @ proguard.classfile.programclass.accept(programclass.java:346) @ proguard.classfile.classpool.classesaccept(classpool.java:125) @ proguard.optimize.optimizer.execute(optimizer.java:565) @ proguard.proguard.optimize(proguard.java:307) @ proguard.proguard.execute(proguard.java:116) @ proguard.ant.proguardtask.execute(proguardtask.java:316) @ org.apache.tools.ant.unknownelement.execute(unknownelement.java:291) @ sun.reflect.generatedmethodaccessor137.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.apache.tools.ant.dispatch.dispatchutils.execute(dispatchutils.java:106) @ org.apache.tools.ant.task.perform(task.java:348) @ org.apache.tools.ant.target.execute(target.java:392) @ org.apache.tools.ant.target.performtasks(target.java:413) @ org.apache.tools.ant.project.executesortedtargets(project.java:1399) @ org.apache.tools.ant.project.executetarget(project.java:1368) @ org.apache.tools.ant.helper.defaultexecutor.executetargets(defaultexecutor.java:41) @ org.apache.tools.ant.project.executetargets(project.java:1251) @ org.apache.tools.ant.module.bridge.impl.bridgeimpl.run(bridgeimpl.java:285) @ org.apache.tools.ant.module.run.targetexecutor.run(targetexecutor.java:539) @ org.netbeans.core.execution.runclassthread.run(runclassthread.java:153)
instead of using option -ignorewarnings, should try solving warnings get. don't mention warnings in question, chances have specified library classes (with -libraryjars) depend on program classes (with -injars), not allowed. cfr. proguard manual > introduction.
Comments
Post a Comment