簡單Android代碼混淆(轉)

代碼混淆步驟:

1,project.properties中打開代碼混淆功能,加入proguard.config=proguard.cfgjava

2,編輯proguard.cfg文件,項目沒有自動生成時可手工新建並放到項目根目錄,內容以下android

-optimizationpasses 5  
-dontusemixedcaseclassnames  
-dontskipnonpubliclibraryclasses  
-dontpreverify  
-verbose  
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*  
-ignorewarnings  
-libraryjars libs/android-support-v4.jar  
  
-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  
  
-libraryjars libs/asmack.jar  
-libraryjars libs/aws-android-sdk-1.7.1.1-core.jar  
-libraryjars libs/aws-android-sdk-1.7.1.1-s3.jar  
-libraryjars libs/LibFrameWidget.jar  
-libraryjars libs/LibFramework.jar  
-libraryjars libs/locSDK_4.0.jar  
-libraryjars libs/umeng_sdk.jar  
-libraryjars libs/zxing-core.jar  
-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 *;  
}

  

應該注意的地方以下:

1,android-support-v4.jar報錯的話,要加上下面的代碼app

-ignorewarningside

-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.Fragmentcode

2,全部Libs下的jar包都要加上引用說明,格式以下(*未對應的jar包名稱)blog

-libraryjars libs/*.jarip

相關文章
相關標籤/搜索