* 配置簽名信息
* 配置ProGuard
在ProGuard中添加proguard.config=proguard.cfg
運行混淆器之後輸出的文件有:
dump.txt
描述.apk包中所有class文件的內部結構。
mapping.txt
列出了源代碼與混淆後的類,方法和屬性名字之間的映射。這個文件對於在構建之後得到的bug報告是有用的,因為它把混淆的堆棧跟蹤信息反翻譯為源代碼中的類,方法和成員名字。更多信息,查看解碼混淆過的堆棧跟蹤信息。
seeds.txt
列出那些未混淆的類和成員。
usage.txt
列出從.apk中剝離的代碼
# 不使用優化方案
-dontoptimize
# 保留簽名,解決泛型問題
-keepattributes Signature
-dontskipnonpubliclibraryclassmembers
-dontskipnonpubliclibraryclasses
#工程中用到的第三方包
-libraryjars libs/android-support-v4.jar
#不混淆第三方包
-keep class android.support.v4.**
#忽略第三方包導致的異常
-dontwarn android.support.v4.**
----------------------------- 異常信息如下
[proguard] Note: there were 1 references to unknown classes.
[proguard] You should check your configuration for typos.
[proguard] Warning: there were 269 unresolved references to classes or interfaces.
[proguard] You may need to specify additional library jars (using '-libraryjars'),
[proguard] or perhaps the '-dontskipnonpubliclibraryclasses' option.
[proguard] Warning: there were 57 unresolved references to program class members.
[proguard] Your input classes appear to be inconsistent.
[proguard] You may need to recompile them and try again.
[proguard] Alternatively, you may have to specify the options
[proguard] '-dontskipnonpubliclibraryclasses' and/or
[proguard] '-dontskipnonpubliclibraryclassmembers'.
BUILD FAILED
D:\android-sdk-windows\tools\ant\build.xml:736: Please correct the above warnings first.
參考資料:
Android 官方教程
http://developer.android.com/tools/help/proguard.html
官方文檔中文翻譯
http://www.cnblogs.com/over140/archive/2011/04/22/2024528.html
ProGuard官方網站
http://proguard.sourceforge.net/
Gson 打包問題
http://blog.csdn.net/codingandroid/article/details/9495405
? Android 導入的包如何處理?
分兩類一類是第三方,一類是自己擁有源碼的動態生成jar的包,需要設置混淆嗎?目前是沒發現要設置