android程式保護、防止反編譯(proguard),簽名打包

來源:互聯網
上載者:User
1 使用proguard防止反編譯   反編譯了很多程式,發現基本上沒有能讀懂的,使用proguard防止反編譯基本上已經普遍了,不會這個怎敢發布程式。 一般人這樣告訴你,2.3就帶了proguard.cfg檔案,2.2沒有(但其實也有了),但你可以拷過去,然後在系統屬性檔案中加入config就行了。proguard.cfg的檔案如下:
-optimizationpasses 5-dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses-dontpreverify-verbose-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*-keep public class * extends android.app.Activity-keep public class * extends android.app.Application-keep public class * extends android.app.Service-keep public class * extends android.content.BroadcastReceiver-keep public class * extends android.content.ContentProvider-keep public class * extends android.app.backup.BackupAgentHelper-keep public class * extends android.preference.Preference-keep public class com.android.vending.licensing.ILicensingService-keepclasseswithmembernames class * {    native <methods>;}-keepclasseswithmembers class * {    public <init>(android.content.Context, android.util.AttributeSet);}-keepclasseswithmembers class * {    public <init>(android.content.Context, android.util.AttributeSet, int);}-keepclassmembers class * extends android.app.Activity {   public void *(android.view.View);}-keepclassmembers enum * {    public static **[] values();    public static ** valueOf(java.lang.String);}-keep class * implements android.os.Parcelable {  public static final android.os.Parcelable$Creator *;}

default.properties檔案內容如下,其實現在是project.properties

# This file is automatically generated by Android Tools.# Do not modify this file -- YOUR CHANGES WILL BE ERASED!## This file must be checked in Version Control Systems.## To customize properties used by the Ant build system use,# "ant.properties", and override values to adapt the script to your# project structure.# Project target.target=android-8proguard.config=proguard.cfg 

2  需要注意的問題 (1)全部設定好後,run下,然後看看bin裡產生的apk,反編譯下。結果還是可以很好的反編譯出來。因為代碼的混淆只有在簽名打包時才有用。簽名打包的最方便方法就是在工程右擊,然後一步步的來就行啦

 一步步的next即可(2)“conversion to dalvik format failed with error 1”,這可能是遇到的第一個問題。有人說clean下工程就行了。如果不行的話就要找到,proguard的在android sdk目錄\tools\proguard\bin\proguard.bat檔案,將

set java_exe=call "%PROGUARD_HOME%"\..\lib\find_java.batcall %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*

改為

set java_exe=call "%PROGUARD_HOME%"\..\lib\find_java.batcall %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9

參見:http://stackoverflow.com/questions/6605971/android-sdk-tools-revision-12-has-problem-with-proguard-error-conversion-to

(3)“proguard returned with error code 1.See console ....找不到檔案”或“proguard
returned with error code 1.See console ....no such directory or file”。錯誤原因:sdk檔案所在目錄,或者工程所在目錄中間有空格,proguard不能識別帶空格的檔案名稱。
(4)還是“proguard
returned with error code 1.See console ....can’t find referenced class”然後是出一堆警告。按提示要加入“-dontskipnonpubliclibraryclasses”,但是檔案中已經有了啊。編程都知道,error不行,但warning應該沒事啊!直接加入“--ignorewarnings ”選項。這樣,基本上就能簽名打包了。

再次反編譯自己的apk,不但自己都看不懂了,而且,體積還小了很多。
相關文章

聯繫我們

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