ProGuard的作用:
1.创建紧凑的代码文档是为了更快的网络传输,快速装载和更小的内存占用.
2.创建的程序和程序库很难使用反向工程.
3.所以它能删除来自源文件中的没有调用的代码
4.充分利用java6的快速加载的优点来提前检测和返回java6中存在的类文件.
参数:
-include {filename} 从给定的文件中读取配置参数
-basedirectory {directoryname} 指定基础目录为以后相对的档案名称
-injars {class_path} 指定要处理的应用程序jar,war,ear和目录
-outjars {class_path} 指定处理完后要输出的jar,war,ear和目录的名称
-libraryjars {classpath} 指定要处理的应用程序jar,war,ear和目录所需要的程序库文件
-dontskipnonpubliclibraryclasses 指定不去忽略非公共的库类。
-dontskipnonpubliclibraryclassmembers 指定不去忽略包可见的库类的成员。
保留选项
-keep {Modifier} {class_specification} 保护指定的类文件和类的成员
-keepclassmembers {modifier} {class_specification} 保护指定类的成员,如果此类受到保护他们会保护的更好
-keepclasseswithmembers {class_specification} 保护指定的类和类的成员,但条件是所有指定的类和类成员是要存在。
-keepnames {class_specification} 保护指定的类和类的成员的名称(如果他们不会压缩步骤中删除)
-keepclassmembernames {class_specification} 保护指定的类的成员的名称(如果他们不会压缩步骤中删除)
-keepclasseswithmembernames {class_specification} 保护指定的类和类的成员的名称,如果所有指定的类成员出席(在压缩步骤之后)
-printseeds {filename} 列出类和类的成员-keep选项的清单,标准输出到给定的文件
压缩
-dontshrink 不压缩输入的类文件
-printusage {filename}
-whyareyoukeeping {class_specification}
优化
-dontoptimize 不优化输入的类文件
-assumenosideeffects {class_specification} 优化时假设指定的方法,没有任何副作用
-allowaccessmodification 优化时允许访问并修改有修饰符的类和类的成员
混淆
-dontobfuscate 不混淆输入的类文件
-printmapping {filename}
-applymapping {filename} 重用映射增加混淆
-obfuscationdictionary {filename} 使用给定文件中的关键字作为要混淆方法的名称
-overloadaggressively 混淆时应用侵入式重载
-useuniqueclassmembernames 确定统一的混淆类的成员名称来增加混淆
-flattenpackagehierarchy {package_name} 重新包装所有重命名的包并放在给定的单一包中
-repackageclass {package_name} 重新包装所有重命名的类文件中放在给定的单一包中
-dontusemixedcaseclassnames 混淆时不会产生形形色色的类名
-keepattributes {attribute_name,...} 保护给定的可选属性,例如LineNumberTable, LocalVariableTable, SourceFile, Deprecated, Synthetic, Signature, and InnerClasses.
-renamesourcefileattribute {string} 设置源文件中给定的字符串常量
Ant Example:
<!-- This Ant build file illustrates how to process applications,
by including ProGuard-style configuration options.
Usage: ant -f applications2.xml -->
<project name="Applications" default="obfuscate" basedir="../..">
<target name="obfuscate">
<taskdef resource="proguard/ant/task.properties"
classpath="lib/proguard.jar" />
<proguard>
<!-- Specify the input jars, output jars, and library jars. -->
-injars in.jar
-outjars out.jar
-libraryjars ${java.home}/lib/rt.jar
<!-- -libraryjars junit.jar -->
<!-- -libraryjars servlet.jar -->
<!-- -libraryjars jai_core.jar -->
<!-- ... -->
<!-- Save the obfuscation mapping to a file, and preserve line numbers. -->
-printmapping out.map
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
<!-- Preserve all annotations. -->
-keepattributes *Annotation*
<!-- Preserve all public applications. -->
-keepclasseswithmembers public class * {
public static void main(java.lang.String[]);
}
<!-- Preserve all native method names and the names of their classes. -->
-keepclasseswithmembernames class * {
native <methods>;
}
<!-- Preserve the methods that are required in all enumeration classes. -->
-keepclassmembers class * extends java.lang.Enum {
public static **[] values();
public static ** valueOf(java.lang.String);
}
<!-- Explicitly preserve all serialization members. The Serializable
interface is only a marker interface, so it wouldn't save them.
You can comment this out if your library doesn't use serialization.
If your code contains serializable classes that have to be backward
compatible, please refer to the manual. -->
-keepclassmembers class * implements 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();
}
<!-- Your application may contain more items that need to be preserved;
typically classes that are dynamically created using Class.forName -->
</proguard>
</target>
</project>
- 浏览: 225952 次
- 性别:
- 来自: 北京
最新评论
-
sfshine:
非常好非常好
Android 窗口管理 -
mthhk:
...
android3.0之Fragment(碎片)基础 -
FrankHB1989:
“C/C++标准不会保证这样的代码一定不会出错”的依据?你要说 ...
Duff's Device -
2006003845:
请问知道 刚体之间怎么不碰撞嘛 ?相互穿插
JBOX2D分析
相关推荐
最好用的JAVA代码混淆工具proguard-7.0.0.zip,稳定、可靠。 最新的JAVA代码混淆工具proguard-7.0.0.zip,先进、速度快。 经实测可以放心使用,无病毒,无木马!
Eclipse+ProGuard配置 Eclipse+ProGuard配置
免费分享,多多支持
java 源码加密 混淆,proguard 配置文件,很详细,经测试可以用
6、proguard混淆首先得根据自己工程具体情况 来决定,哪些类需要混淆,哪些 类不能混淆,对包名、类名、方法名、参数名、变量名等其它信息 如何处理 可以通过参数 配置。 7、别忘记加上参数 printmapping obf.map...
java代码混淆工具 简单使用docx 字典文件 生成的配置示例
Java 代码 混淆 工具 proguard 4.5.1
实用的java代码混淆器proguard3.2下载(内有实例,教你怎么用)
proguard混淆打包工具proguard混淆打包工具proguard混淆打包工具
ProGuard是一款免费的Java类文件压缩器、优化器和混淆器。它能发现并删除无用类、字段(field)、方法和属性值(attribute)。它也能优化字节码并删除无用的指令。最后,它使用简单无意义的名字来重命名你的类名、...
Android Java代码混淆工具:ProGuard简介及使用.docx
最新的加密混淆工具,找了几个都不能用。终于找了个最新版本
java代码混淆器proGuard,可以混淆函数变量、类、方法名以实现代码加密
经典的Java代码混淆工具,可以混淆class,jar类型的文件,防止被反编译,对需要进行源码保护的代码很有用。
最新混淆包proguard6.0.3
最新混淆工具,支持springboot jdk18 ,内有示例及ant,可以打包生成jar包后直接生成加密包
很好用的一个代码混淆工具,混淆后可以防止被反编译。很容易用。
代码混淆攻击 可集成于ECLIPSE 使用非常方便 J2ME程序经常要用到混淆
代码混淆工具-proguard7.2.2
本实例使用的是把web项目中的源码(src)所有文件打包成jar文件,使用proguard混淆后再把jar文件以及jar解压后的混淆class类文件替换原war项目的相应位置即可。 混淆过程中需要使用keep参数来保持原有一些属性、注解...