I tried to learn how to use ProGuard , and it is not as easy as I thought. First I found simple Java code to try it, a simple two-class Swing calculator .
The code can be found by clicking on this link, but I found it too detailed to publish it here. Anyway, this is a simple application with an entry point on Calc.main() , there are no packages.
Then I compiled both sources with:
$ javac *.java
and created the .jar file (because it seems that ProGuard only works with banks):
$ jar cvef Calc calc.jar *.class added manifest adding: Calc.class(in = 3869) (out= 2126)(deflated 45%) adding: Calc$ClearListener.class(in = 468) (out= 327)(deflated 30%) adding: CalcLogic.class(in = 1004) (out= 515)(deflated 48%) adding: Calc$NumListener.class(in = 1005) (out= 598)(deflated 40%) adding: Calc$OpListener.class(in = 1788) (out= 1005)(deflated 43%)
Wrote a ProGuard file named obfuscate.pro :
-injars calc.jar -outjars calc_obf.jar -libraryjars <java.home>/lib/rt.jar -keep public class Calc extends javax.swing.JFrame { public static void main(java.lang.String[]); }
And finally, launch ProGuard:
$ ~/progs/proguard/proguard4.8/bin/proguard.sh @obfuscate.pro ProGuard, version 4.8 Reading program jar [/home/lucas/tmp/calc.jar] Reading library jar [/usr/lib/jvm/java-7-openjdk-i386/jre/lib/rt.jar] Error: The output jar is empty. Did you specify the proper '-keep' options?
Well, obviously, it didn’t work out. I'm tired of messing with the ProGruard options, especially with these -keep options, without success. Everything that I found in the documents related to my problem could not help me. Then I come running to you ... What's wrong? How to do it right?
source share