proguard簡介

首先附上官網的地址:http://proguard.sourceforge.net/

並未完全介紹,選擇其中的一部分來介紹

manual:proguard 指南 菜單項

一些基礎的命令:

運行proguard

java -jar proguard.jar options ...

配置自己設置

java -jar proguard.jar @myconfig.pro

命令行執行配置

java -jar proguard.jar @myconfig.pro -xxx


1  inputs/outputs


 -include filename   從給定的文件名讀取配置項

-basedirectory directoryname  指定基本路徑

-injars classpath   指定該應用jar包引用路徑

-outjars  classpath 

-libraryjars  classpath  指定類庫路徑

-skipnonpubliclibraryclasses  跳過非公共類

-dontskipnonpubliclibraryclasses 

-keepdirectories  [directory-filter]

-target version 

-forceprocessing 


2 keep options

-keep [,modifiers...] class specification 保證有入口點(此處指類)
-keepclassmembers [,modifiers...] class specification 保證類成員(此處只是聲明類的成員)
-keepclasseswithmembers [,modifiers....]   class   specification 保留類及其內部成員
-keepnames  class specification  保留被shrink後的類及其成員
-keepclassmembernames  class specification   保留被shrink後的類成員
-keppclasseswithmembernames  class  specification   保留shrink後類及其成員
-printseeds [filename ]  列出被保護的類及其成員到指定filename

3 shrinking options

-dontshrink   Specifies not to shrink the input class files
-printusage [filename]   在指定filename文件中列出dead code
-whyareyoukeeping  class specification

4 optimize options

-dontoptimize 和許多optimize命令,此處見官網


5 obfuscation options

-dontobfuscation  
-keeppackagenames  [package-filter]

還有其他,見官網

6 preverification options

-dontpreverify
-microedition

7 general options

-verbose
-dontnote   [class-filter]
-dontwarn  [class-filter]
-ignorewarnings 
 

8 class paths

each input entry  can be :

  • A class file or resource file,
  • An apk file, containing any of the above,
  • A jar file, containing any of the above,
  • An aar file, containing any of the above,
  • A war file, containing any of the above,
  • An ear file, containing any of the above,
  • A zip file, containing any of the above,
  • A directory (structure), containing any of the above
each output entry can be:

  • An apk file, in which all class files and resource files will be collected.
  • A jar file, in which any and all of the above will be collected,
  • An aar file, in which any and all of the above will be collected,
  • A war file, in which any and all of the above will be collected,
  • An ear file, in which any and all of the above will be collected,
  • A zip file, in which any and all of the above will be collected,
  • A directory, in which any and all of the above will be collected.

files  and directories can be specifies :

  • A filter for all aar names that are encountered,
  • A filter for all apk names that are encountered,
  • A filter for all zip names that are encountered,
  • A filter for all ear names that are encountered,
  • A filter for all war names that are encountered,
  • A filter for all jar names that are encountered,
  • A filter for all class file names and resource file names that are encountered.

9 file names

a relative path is interpreted as below:

  • relative to the base directory, if set, or otherwise
  • relative to the configuration file in which it is specified, if any, or otherwise
  • relative to the working directory.





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章