在Android4.0以前的版本建的工程中有一個proguard.cfg文件,混淆時直接將混淆代碼加進去,而後在project.properties這個文件底下加入proguard.config=proguard.cfg這句話就能夠了; java
在4.0版本建的工程中發現proguard.cfg沒了,多了proguard-project.txt這個文件。反正我沒管,直接將 proguard.cfg這個文件拷過去用了,沒發現什麼問題,下面是混淆時proguard.cfg中的代碼: android
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keepattributes *Annotation*
-keepattributes JavascriptInterface
-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 *;
} apache
//這些須要說明,這是工程中引入的第三方的類庫,不須要咱們作混淆,由於人家已經作過混淆處理了 ,-keep關鍵字修飾的一些都是不須要混淆處理的
-libraryjars libs/android-support-v4.jar
-libraryjars libs/commons-io-1.3.2.jar
-libraryjars libs/library.jar
-libraryjars libs/pushservice-2.4.0.jar
-libraryjars libs/nineoldandroids-2.4.0.jar
## commons-io-1.3.2.jar
-keep public class org.apache.commons.** {*;}
## support-v4
-dontwarn android.support.v4.**
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep public class * extends android.support.v4.**
-keep public class * extends android.app.Fragment
## annotations.jar
-keep public class android.annotation {*;}
## pushservice-2.4.0.jar
-keep public class android.content.pm {*;}
-keep public class android.baidu.** {*;}
## nineoldandroids-2.4.0.jar
-keep public class com.nineoldandroids.** {*;}
## library.jar
-keep public class com.nostra13.universalimageloader.** {*;}
## kxml2-min-2.3.0.jar
-keep public class org.** {*;}
app
最後別忘了將proguard.config=proguard.cfg這句話加入到project.properties這個文件下面 ide