使用proguard进行混淆

时间:2012-01-04 06:25:33

标签: java obfuscation proguard

我已经使用proguard来混淆我的java类。完成混淆过程后,我使用java反编译器反编译我的java类,那时我的类名,方法和变量没有被重命名,它被打开而没有任何改变命名我在写代码时给出的内容。我不知道我在哪里做错了配置文件

injars 'E:\vsd_02\workplace\pro\dist\pro.jar'
-outjars 'E:\vsd_02\workplace\pro\dist\pro_out.jar'

-libraryjars 'C:\Program Files\Java\jre7\lib\rt.jar'

-forceprocessing
-printmapping 'E:\vsd_02\workplace\pro\dist\pro.map'
-repackageclasses ''
-renamesourcefileattribute SourceFile
-verbose
-dontwarn


# Keep - Applications. Keep all application classes, along with their 'main'
# methods.
-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
}

# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum  * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# Also keep - Serialization code. Keep all fields and methods that are used for
# serialization.
-keepclassmembers class * extends java.io.Serializable {
    static final long serialVersionUID;
    static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# Also keep - Bean classes. Keep all specified classes, along with their getters
# and setters.
-keep class * {
    void set*(***);
    void set*(int,***);
    boolean is*();
    boolean is*(int);
    *** get*();
    *** get*(int);
}

# Also keep - Database drivers. Keep all implementations of java.sql.Driver.
-keep class * extends java.sql.Driver

# Also keep - Swing UI L&F. Keep all extensions of javax.swing.plaf.ComponentUI,
# along with the special 'createUI' method.
-keep class * extends javax.swing.plaf.ComponentUI {
    public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent);
}

# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembers,allowshrinking class * {
    native <methods>;
}

1 个答案:

答案 0 :(得分:0)

此设置已使所有类保持其原始名称(如文档所述):

# Also keep - Bean classes. Keep all specified classes, along with their getters
# and setters.
-keep class * {
    .....
}

另请参阅ProGuard手册&gt;疑难解答&gt;处理后的意外观察&gt; Variable names not being obfuscated