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 &lt;methods&gt;;
    }

<!-- 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>

ProGuard的作用相关推荐

  1. ProGuard的作用、使用及bug分析

    http://www.trinea.cn/android/proguard-use/ 本文主要ProGuard的作用.使用及bug分析. 1.ProGuard作用 ProGuard通过删除无用代码,将 ...

  2. Proguard 部分类不混淆的技巧

    Proguard 部分类不混淆的技巧 最近比较忙,博客和 codeKK 都两个月没怎么更新了.赶在月末分享个小技巧. 一.场景 两年前在 Proguard 语法及常用 proguard.cfg 代码  ...

  3. 【Android 安全】DEX 加密 ( Proguard 简介 | Proguard 相关网址 | Proguard 混淆配置 )

    文章目录 一.Proguard 简介 二.Proguard 相关网址 三.Proguard 混淆配置 一.Proguard 简介 Android 开发中 Proguard 主要作用是对 Java 代码 ...

  4. Proguard的介绍

     一. ProGuard是一个免费的Java类文件压缩.优化.混淆器和审核器,它检查并删除没有使用到的类.字段.方法和属性.它优化字节码并去除没有使用到的指令,它使用无意义的名字来重命名使用的类.字段 ...

  5. proguard.cfg(转载)

    ProGuard简介 ProGuard是一个SourceForge上非常知名的开源项目.官网网址是:http://proguard.sourceforge.net/. Java的字节码一般是非常容易反 ...

  6. 关于Android Studio里的Gradle文件

    // 声明是Android程序 //apply plugin是最新gradle版本的写法,以前的写法是apply plugin: 'android', 如果还是以前的写法,请改正过来 apply pl ...

  7. Android内存分析和调优

    最近我们的android app占用了大量内存,于是领导安排做减少内存占用的工作. 要优化内存,首先要做的就是分析内存占用情况.android提供了多个工具和命令进行内存分析. 第一层 Procran ...

  8. android 内存分析 名词解释,Android内存分析和调优(下)

    出自:http://www.cnblogs.com/zdwillie/p/3287150.html 最后一部分是关于native heap,.dex,/dev/other的优化.​ Native He ...

  9. 安卓应用(APK)逆向工程

    原文参考链接:https://crifan.github.io/android_app_security_crack/website/ 上述网址讲解的非常详细,这里只粗略的整理用到的比较多的工具以及一 ...

最新文章

  1. 人类偏好的“可塑性”,从博弈说起
  2. 推荐一些顶级的Android开发书籍(转)
  3. 不要再问我“Java GC垃圾回收机制”了
  4. .net后台获取html控件值的2种方法
  5. .frm_.myd_myi转换为.sql导入mysql数据库_把.frm,.myd,myi转换为.sql导入数据库
  6. GitHub之深入解析如何对项目做出贡献
  7. js中的extend的用法及其JS中substring与substr的区别
  8. python使用glob模块匹配文件及路径
  9. sublime text插件与快捷键
  10. Python:查找天气预报json接口的城市代码(A)
  11. 关于flash播放器不为人知的四大点
  12. 物联网和区块链:挑战与风险
  13. 漫步者lollipods如何调节音量_Edifer 漫步者 Lolli pods 评测及对一些问题的实际体验...
  14. bitcoin轻钱包之SPV验证
  15. 搭建gos_快速浏览gOS –但不要称其为Google
  16. SNARK Design
  17. CMD命令行高级教程精选合编合集 转
  18. 怎么制定市场营销策划方案
  19. POJ 2263 Heavy Cargo
  20. Xiaojie雷达之路---雷达原理(二刷)脉冲法测距

热门文章

  1. 关于股市里的那些事,学会选股;赢在起跑线
  2. 自学C++编程,掌握这三项技能就可以工作了
  3. mysql的配置中主机地址怎么填_连接到mysql主机数据库配置命令-mysql主机地址
  4. PTA 1108 String复读机(Python3)
  5. 蓝色基因 p超级计算机,蓝色巨人推出全球最快计算机蓝色基因 代号P
  6. Java设计模式中组合模式是什么/树形结构怎么组合或显示存储,编程怎么实现树形结构
  7. [JAVA]数字摘要算法工具类——(Hamc)MD5/SHA1/SHA256/SHA512/PBKDF2
  8. java标签添加图片_Java添加图片(标签)
  9. 正则表达式,生成器,迭代器
  10. 函数的参数作为引用时的一些问题