开源混淆工具ProGuard配置详解及配置实例
来源:互联网 发布:谷得网络 编辑:程序博客网 时间:2024/06/08 06:15
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>
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>
0 0
- 开源混淆工具ProGuard配置详解及配置实例
- 开源混淆工具ProGuard配置详解及配置实例
- 开源混淆工具ProGuard配置详解及配置实例
- 开源混淆工具ProGuard配置详解及配置实例
- 开源混淆工具ProGuard配置详解及配置实例
- 开源混淆工具ProGuard配置详解及配置实例
- android打包混淆-proguard配置详解
- 混淆配置proguard 原理
- netty 混淆配置proguard
- proguard混淆配置参数
- ProGuard混淆配置
- Android Proguard工具使用和配置详解
- Eclipse+ProGuard配置混淆器
- android 混淆配置proguard 原理
- Android Studio:ProGuard 混淆配置
- 关于混淆proguard的配置
- Android项目:第三方Jar包proguard混淆之常见开源项目混淆配置
- Android项目:proguard混淆之常见开源项目混淆配置
- Java之美[从菜鸟到高手演练]之Comparator和Comparable在排序中的应用
- IE7 下执行jquery, 报错IE error: Expected identifier, string or number 的解决办法
- lucene索引库优化一
- 第三章再续:伴随数组求数组中给定下标区间内的第K小(大)元素
- wifi下一个传多个策略思考
- 开源混淆工具ProGuard配置详解及配置实例
- 关于更新博客
- 2014年技术规划
- JavaScript 新窗口与子窗口 传值
- linux thread pool demo
- 1:我爱北大
- 解决android生成doc文档,找不到符号报错问题
- Java之美[从菜鸟到高手演变]之XML的打包与解析 .
- Ubuntu下安装以及配置Samba