码迷,mamicode.com
首页 > 移动开发 > 详细

android 代码混淆示例

时间:2014-07-02 14:42:33      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   http   java   color   

参考其它资料为项目代码做了一下混淆

项目中使用了 slidingmenu   actionbarsherlock   fastjson  volley   httpclient 等第三方库,

并使用了  webview + js ,  有微信和微博分享功能。 

# 指定代码的压缩级别
-optimizationpasses 5                                                          
-dontusemixedcaseclassnames    
# 是否混淆第三方jar                                                  
-dontskipnonpubliclibraryclasses                                               
-dontpreverify                                                                  
-keepattributes SourceFile,LineNumberTable                                         
-verbose                                                                        
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*        

-libraryjars libs/httpmime-4.1.3.jar
-libraryjars libs/libammsdk.jar
-libraryjars libs/fastjson-1.1.34.android.jar
-libraryjars libs/commons-lang.jar
-libraryjars libs/weibosdkcore.jar

# webview + js
# keep 使用 webview 的类
-keepclassmembers class com.goldnet.mobile.activity.InfoDetailActivity {
   public *;
}
# keep 使用 webview 的类的所有的内部类
-keepclassmembers   class com.goldnet.mobile.activity.InfoDetailActivity$*{
    *;
}

# 保持哪些类不被混淆
-keep class android.** {*; }
-keep public class * extends android.view  
-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.pm                                
-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             

#ACRA specifics
# we need line numbers in our stack traces otherwise they are pretty useless
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

# ACRA needs "annotations" so add this... 
-keepattributes *Annotation*

# 保持 native 方法不被混淆
-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);     
}

-keepclasseswithmembers class * {
    void onClick*(...);
}
-keepclasseswithmembers class * {
    *** *Callback(...);
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

# 保持自定义控件类不被混淆
-keepclassmembers class * extends android.app.Activity {                       
   public void *(android.view.View);
}

# 保持枚举 enum 类不被混淆
-keepclassmembers enum * {                                                     
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# 保持 Parcelable 不被混淆
-keep class * implements android.os.Parcelable {                             
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

# http client
-keep class org.apache.http.** {*; }

# 微信
-keep class com.tencent.mm.sdk.openapi.WXMediaMessage {*;}
-keep class com.tencent.mm.sdk.openapi.** implements com.tencent.mm.sdk.openapi.WXMediaMessage$IMediaObject {*;}
 
# fastjson
-keep class com.alibaba.fastjson.**{*;}
# keep 所有的 javabean
-keep class com.goldnet.mobile.entity.**{*;}   
# keep 泛型
-keepattributes Signature
  
#-keep public class * implements java.io.Serializable {  
#    public *;  
#}  
  
#-keepclassmembers class * implements java.io.Serializable {  
#    static final long serialVersionUID;  
#    private static final java.io.ObjectStreamField[] serialPersistentFields;  
#    private void writeObject(java.io.ObjectOutputStream);  
#    private void readObject(java.io.ObjectInputStream);  
#    java.lang.Object writeReplace();  
#    java.lang.Object readResolve();  
#} 

-keep class org.apache.commons.lang.**{*;}

# 新浪微博
-keep class com.sina.**{*;}

#######
# 其它第三方库
#######
-dontwarn org.bouncycastle.**
-keep class org.bouncycastle.**{*;}

-dontwarn android-async-http-1.4.4.jar.**
-keep class android-async-http-1.4.4.jar.**{*;}

-dontwarn Decoder.**
-keep class Decoder.**{*;}

# volley
-dontwarn com.android.volley.jar.**
-keep class com.android.volley.**{*;}
 
# actionbarsherlock
-dontwarn com.actionbarsherlock.**
-keep class com.actionbarsherlock.**{*;}

# slidingmenu
-dontwarn com.jeremyfeinstein.slidingmenu.lib.**
-keep class com.jeremyfeinstein.slidingmenu.lib.**{*;}

-dontwarn com.cairh.app.sjkh.**
-keep class com.cairh.app.sjkh.**{*;}

 

android 代码混淆示例,布布扣,bubuko.com

android 代码混淆示例

标签:android   style   blog   http   java   color   

原文地址:http://www.cnblogs.com/lesliefang/p/3819259.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!