Android Proguard 簡單學習

來源:互聯網
上載者:User


* 配置簽名資訊
* 配置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的包,需要設定混淆嗎?目前是沒發現要設定



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.