Android開發代碼混淆經驗(Eclipse)

來源:互聯網
上載者:User

標籤:

為了防止自己的勞動成果被別人竊取,混淆代碼能有效防止被反編譯,下面來總結以下混淆代碼的步驟:

 

2、編輯項目下的proguard-project.txt,添加不需要混淆的規則(model、泛型、反射、第三方jar包),proguard-project.txt檔案內容如下:

# To enable ProGuard in your project, edit project.properties# to define the proguard.config property as described in that file.## Add project specific ProGuard rules here.# By default, the flags in this file are appended to flags specified# in ${sdk.dir}/tools/proguard/proguard-android.txt# You can edit the include path and order by changing the ProGuard# include property in project.properties.## For more details, see#   http://developer.android.com/guide/developing/tools/proguard.html# Add any project specific keep options here:# If your project uses WebView with JS, uncomment the following# and specify the fully qualified class name to the JavaScript interface# class:#-keepclassmembers class fqcn.of.javascript.interface.for.webview {#   public *;#}############################################## 主程式不能混淆的代碼 ####################################################-dontwarn xxx.model.**######-keep class xxx.model.** { *; }################################################ 不最佳化泛型和反射 ###############################################-keepattributes Signature-keep class * extends java.lang.annotation.Annotation { *; }############################################## 不混淆第三方庫或者jar包 ############################################-dontwarn net.sourceforge.jtds.**-keep class net.sourceforge.jtds.** { *; }-dontwarn com.iflytek.speech.**-keep class com.iflytek.speech.** { *; }-dontwarn com.lidroid.xutils.**-keep class com.lidroid.xutils.** { *; }#####################################

技巧:第三方jar包包名可以用WinRAR來開啟jar檔案,擷取包路徑。例如:jtds-1.2.jar,用WinRAR查看,可以發現包名為:net.sourceforge.jtds,所以只需要添加如下2行代碼,即可不混淆該jar檔案的相關包和類:

-dontwarn net.sourceforge.jtds.**-keep class net.sourceforge.jtds.** { *; }



參考文章:
1、http://blog.csdn.net/lovexjyong/article/details/24652085
2、http://www.cnblogs.com/qianxudetianxia/p/4948499.html


 

Android開發代碼混淆經驗(Eclipse)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.