Home | History | Annotate | Download | only in examples
      1 #
      2 # This ProGuard configuration file illustrates how to process a program
      3 # library, such that it remains usable as a library.
      4 # Usage:
      5 #     java -jar proguard.jar @library.pro
      6 #
      7 
      8 # Specify the input jars, output jars, and library jars.
      9 # In this case, the input jar is the program library that we want to process.
     10 
     11 -injars  in.jar
     12 -outjars out.jar
     13 
     14 -libraryjars  <java.home>/lib/rt.jar
     15 
     16 # Save the obfuscation mapping to a file, so we can de-obfuscate any stack
     17 # traces later on. Keep a fixed source file attribute and all line number
     18 # tables to actually get these stack traces.
     19 # You can comment this out if you're not interested in stack traces.
     20 
     21 -printmapping out.map
     22 -renamesourcefileattribute SourceFile
     23 -keepattributes Exceptions,InnerClasses,Signature,Deprecated,
     24                 SourceFile,LineNumberTable,EnclosingMethod
     25 
     26 # Preserve all annotations.
     27 
     28 -keepattributes *Annotation*
     29 
     30 # Preserve all public classes, and their public and protected fields and
     31 # methods.
     32 
     33 -keep public class * {
     34     public protected *;
     35 }
     36 
     37 # Preserve all .class method names.
     38 
     39 -keepclassmembernames class * {
     40     java.lang.Class class$(java.lang.String);
     41     java.lang.Class class$(java.lang.String, boolean);
     42 }
     43 
     44 # Preserve all native method names and the names of their classes.
     45 
     46 -keepclasseswithmembernames class * {
     47     native <methods>;
     48 }
     49 
     50 # Preserve the special static methods that are required in all enumeration
     51 # classes.
     52 
     53 -keepclassmembers class * extends java.lang.Enum {
     54     public static **[] values();
     55     public static ** valueOf(java.lang.String);
     56 }
     57 
     58 # Explicitly preserve all serialization members. The Serializable interface
     59 # is only a marker interface, so it wouldn't save them.
     60 # You can comment this out if your library doesn't use serialization.
     61 # If your code contains serializable classes that have to be backward
     62 # compatible, please refer to the manual.
     63 
     64 -keepclassmembers class * implements java.io.Serializable {
     65     static final long serialVersionUID;
     66     static final java.io.ObjectStreamField[] serialPersistentFields;
     67     private void writeObject(java.io.ObjectOutputStream);
     68     private void readObject(java.io.ObjectInputStream);
     69     java.lang.Object writeReplace();
     70     java.lang.Object readResolve();
     71 }
     72 
     73 # Your library may contain more items that need to be preserved; 
     74 # typically classes that are dynamically created using Class.forName:
     75 
     76 # -keep public class mypackage.MyClass
     77 # -keep public interface mypackage.MyInterface
     78 # -keep public class * implements mypackage.MyInterface
     79