ProGuard是什麼,做什麼用,不在這個地方介紹了,參考 ProGuard使用簡介 http://www.linuxidc.com/Linux/2013-08/88155.htm。這裡只提一下使用ProGuard需要注意的幾個地方:
1、注意版本,如果不是項目需要,最好使用最新穩定版本,這樣出錯的機會小一些,學習曲線會明顯縮短。
2、最好以源碼的同編譯版本的jvm來啟動proguardgui.jar,不要直接用默認的jvm打開。
3、注意proguaardgui啟動後默認加載的libraryjar中包含的rt.jar,它的版本和你使用到的jvm版本一致。
4、使用1.4的jvm打開proguard時,注意在optimization選項卡中,不要勾中keep enumerations選項,因為勾中這個選項會導致configration文件中出現java.lang.Enum,這個類
只有在1.5的環境下才有。報錯信息如下:
[proguard] Note: the configuration refers to the unknown class 'java.lang.Enum'
[proguard] Note: there were 1 references to unknown classes.
[proguard] You should check your configuration for typos.
5、嵌入ant腳本時,通常會有這麼一段
<target name="proguard" depends="init">
<taskdef resource="proguard/ant/task.properties" classpath="${lib.dir}/proguard/proguard.jar" />
<proguard configuration="${src.dir}/config.pro" />
</target>
task.properties在proguard.jar中,保留,config.pro是proguard的配置文件,最好使用proguardgui.jar先生成,然後再根據需求手動修改。
ProGuard 的詳細介紹:請點這裡
ProGuard 的下載地址:請點這裡