Monday, August 3, 2015

Android 如何做代码混淆?



这里的代码混淆 直接 copy 到 proguard-project.txt  或者 proguard-cfg.txt 都可以的!


-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 *;
}

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

-dontwarn android.support.v4.**
-keep class android.support.v4.** { *; }
-keep public class * extends android.support.v4.**
-keep public class * extends android.app.Fragment

-keep class com.tencent.mm.sdk.openapi.WXMediaMessage {*;}
-keep class com.tencent.mm.sdk.openapi.** implements com.tencent.mm.sdk.openapi.WXMediaMessage$IMediaObject {*;}

-dontwarn android.net.http.**
-keep public class android.webkit.WebView {*;}
-keep public class android.webkit.WebViewClient {*;}
-keep class com.weibo.net.** {*;}

#third jar proguard
-dontwarn android.support.**
-keep class android.support.** { *; }

-dontwarn org.android.**
-keep class org.android.** { *; }

-dontwarn  com.umeng.analytics.**
-keep class com.umeng.analytics.** { *; }

-dontwarn  u.aly.**
-keep class u.aly.** { *; }

-dontwarn net.tsz.afinal.**
-keep class net.tsz.afinal.** { *; }

-dontwarn com.baidu.**
-keep class com.baidu.** { *; }

-dontwarn com.yintong.**
-keep class com.yintong.** { *; }

-dontwarn cn.sharesdk.tencent.qzone.**
-keep class cn.sharesdk.tencent.qzone.** { *; }

-dontwarn cn.sharesdk.tencent.weibo.**
-keep class cn.sharesdk.tencent.weibo.** { *; }

-dontwarn cn.sharesdk.tencent.qq.**
-keep class cn.sharesdk.tencent.qq.** { *; }

-dontwarn cn.sharesdk.facebook.**
-keep class cn.sharesdk.facebook.** { *; }

-dontwarn cn.sharesdk.wechat.utils.**
-keep class cn.sharesdk.wechat.utils.** { *; }

-dontwarn cn.sharesdk.wechat.friends.**
-keep class cn.sharesdk.wechat.friends.** { *; }

-dontwarn cn.sharesdk.wechat.favorite.**
-keep class cn.sharesdk.wechat.favorite.** { *; }

-dontwarn cn.sharesdk.wechat.moments.**
-keep class cn.sharesdk.wechat.moments.** { *; }

-dontwarn cn.sharesdk.twitter.**
-keep class cn.sharesdk.twitter.** { *; }

-dontwarn cn.sharesdk.sina.weibo.**
-keep class cn.sharesdk.sina.weibo.** { *; }

-dontwarn com.sina.sso.**
-keep class com.sina.sso.** { *; }

-dontwarn cn.sharesdk.system.text.**
-keep class cn.sharesdk.system.text.** { *; }

-dontwarn cn.sharesdk.framework.**
-keep class cn.sharesdk.framework.** { *; }

-dontwarn com.tencent.mm.**
-keep class com.tencent.mm.** { *; }

-dontwarn m.framework.**
-keep class m.framework.** { *; }

-dontwarn com.google.gson.**
-keep class com.google.gson.** { *; }

-dontwarn org.apache.commons.net.**
-keep class org.apache.commons.net.** { *; }

#umeng proguard
-dontshrink
-dontoptimize
-dontwarn com.google.android.maps.**
-dontwarn android.webkit.WebView
-dontwarn com.umeng.**
-dontwarn com.tencent.weibo.sdk.**
-dontwarn com.facebook.**

-keep enum com.facebook.**
-keepattributes Exceptions,InnerClasses,Signature
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable

-keep public interface com.facebook.**
-keep public interface com.tencent.**
-keep public interface com.umeng.socialize.**
-keep public interface com.umeng.socialize.sensor.**
-keep public interface com.umeng.scrshot.**

-keep public class com.umeng.socialize.* {*;}
-keep public class javax.**
-keep public class android.webkit.**

-keep class com.facebook.**
-keep class com.umeng.scrshot.**
-keep public class com.tencent.** {*;}
-keep class com.umeng.socialize.sensor.**

-keep class com.tencent.mm.sdk.modelmsg.WXMediaMessage {*;}

-keep class com.tencent.mm.sdk.modelmsg.** implements com.tencent.mm.sdk.modelmsg.WXMediaMessage$IMediaObject {*;}

-keep class im.yixin.sdk.api.YXMessage {*;}
-keep class im.yixin.sdk.api.** implements im.yixin.sdk.api.YXMessage$YXMessageData{*;}

-keep public class [your_pkg].R$*{
    public static final int *;
}

-keepattributes Signature

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keep class com.google.gson.examples.android.model.** { *; }
-keep class com.google.gson.** { *;}




No comments:

Post a Comment