Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android 程序代碼混淆 proguard 腳本 proguard.cfg

android 程序代碼混淆 proguard 腳本 proguard.cfg

編輯:關於Android編程

android 代碼混淆 1 proguard.cfg,這就是混淆所需的proguard腳本啊。   其代碼如下:   [java]   view plain   -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 com.android.vending.licensing.ILicensingService    -keepclasseswithmembernames class * {        native <methods>;    }    -keepclasseswithmembernames class * {        public <init>(android.content.Context, android.util.AttributeSet);    }    -keepclasseswithmembernames class * {        public <init>(android.content.Context, android.util.AttributeSet, int);    }    -keepclassmembers enum * {        public static **[] values();        public static ** valueOf(java.lang.String);    }    -keep class * implements android.os.Parcelable {      public static final android.os.Parcelable$Creator *;    }      從腳本中可以看到,混淆中保留了繼承自Activity、Service、Application、BroadcastReceiver、ContentProvider等基本組件。 並保留了所有的Native變量名及類名,所有類中部分以設定了固定參數格式的構造函數,枚舉等等。(詳細信息請參考<proguard_path>/examples中的例子及注釋。) 2 在工程的"default.properties"中添加這樣一句話“proguard.config=proguard.cfg”     打包簽名後的.apk就是混淆的,其實我們只要做一步就可以了就是在"default.properties"中添加這樣一句話“proguard.config=proguard.cfg”就可以了。   出現錯誤: [INFO] Warning: there were 294 unresolved references to classes or interfaces. [INFO]          You may need to specify additional library jars (using '-library jars'). [INFO] Warning: there were 3 unresolved references to program class members.       You should consider explicitly keeping the mentioned class members       (using '-keep' or '-keepclassmembers'). [INFO]          Your input classes appear to be inconsistent. [INFO]          You may need to recompile them and try again. [INFO]          Alternatively, you may have to specify the option [INFO]          '-dontskipnonpubliclibraryclassmembers'. [INFO] java.io.IOException: Please correct the above warnings first. [INFO]  at proguard.Initializer.execute(Initializer.java:321) [INFO]  at proguard.ProGuard.initialize(ProGuard.java:211) [INFO]  at proguard.ProGuard.execute(ProGuard.java:86) [INFO]  at proguard.ProGuard.main(ProGuard.java:492) 解決方法如下:解決方法找到了,在proguard.cfg文件中加入-ignorewarnings就可以跳過這個錯誤了。  
  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved