android混淆傻瓜式教程,直接拿去用

轉(zhuǎn)載自: http://blog.csdn.net/u012188405/article/details/51985273

Add project specific ProGuard rules here.

By default, the flags in this file are appended to flags specified

in D:\android-sdk-windows/tools/proguard/proguard-android.txt

You can edit the include path and order by changing the proguardFiles

directive in build.gradle.

For more details, see

http://developer.android.com/guide/developing/tools/proguard.html

Add any project specific keep options here:

If your project uses WebView with JS, uncomment the following

and specify the fully qualified class name to the JavaScript interface

class:

-keepclassmembers class fqcn.of.javascript.interface.for.webview {

public *;

}

copyright zhonghanwen

-------------------------------------------基本不用動(dòng)區(qū)域--------------------------------------------

---------------------------------基本指令區(qū)----------------------------------

-optimizationpasses 5
-dontskipnonpubliclibraryclassmembers
-printmapping proguardMapping.txt
-optimizations !code/simplification/cast,!field/,!class/merging/
-keepattributes Annotation,InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable

----------------------------------------------------------------------------

---------------------------------默認(rèn)保留區(qū)---------------------------------

繼承activity,application,service,broadcastReceiver,contentprovider....不進(jìn)行混淆

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.support.multidex.MultiDexApplication
-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 * extends android.view.View
-keep public class com.android.vending.licensing.ILicensingService
-keep class android.support.** {*;}

-keep public class * extends android.view.View{
*** get();
void set
(***);
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
}

這個(gè)主要是在layout 中寫的onclick方法android:onclick="onClick",不進(jìn)行混淆

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-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 *.R$ {
*;
}

-keepclassmembers class * {
void (Event);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

// natvie 方法不混淆

-keepclasseswithmembernames class * {
native <methods>;
}

保持 Parcelable 不被混淆

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

----------------------------------------------------------------------------

---------------------------------webview------------------------------------

-keepclassmembers class fqcn.of.javascript.interface.for.Webview {
public *;
}
-keepclassmembers class * extends android.webkit.WebViewClient {
public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
public boolean *(android.webkit.WebView, java.lang.String);
}
-keepclassmembers class * extends android.webkit.WebViewClient {
public void *(android.webkit.WebView, jav.lang.String);
}

----------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------

---------------------------------實(shí)體類---------------------------------

修改成你對(duì)應(yīng)的包名
-keep class [your_pkg].** { *; }

---------------------------------第三方包-------------------------------

支付寶支付

-keep class com.alipay.android.app.IAlixPay{;}
-keep class com.alipay.android.app.IAlixPay$Stub{
;}
-keep class com.alipay.android.app.IRemoteServiceCallback{;}
-keep class com.alipay.android.app.IRemoteServiceCallback$Stub{
;}
-keep class com.alipay.sdk.app.PayTask{ public *;}
-keep class com.alipay.sdk.app.AuthTask{ public *;}
-keep public class * extends android.os.IInterface

微信支付

-keep class com.tencent.mm.sdk.openapi.WXMediaMessage {;}
-keep class com.tencent.mm.sdk.openapi.
* implements com.tencent.mm.sdk.openapi.WXMediaMessage$IMediaObject {;}
-keep class com.tencent.wxop.
* { ; }
-dontwarn com.tencent.mm.
*
-keep class com.tencent.mm.*{;}
-keepclasseswithmembernames class ** {
}
-keepattributes Signature

-keep class sun.misc.Unsafe { *; }

-keep class com.taobao.** {;}
-keep class com.alibaba.
* {;}
-keep class com.alipay.
* {;}
-dontwarn com.taobao.
*
-dontwarn com.alibaba.**
-dontwarn com.alipay.**

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

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

-keep class anet.{;}
-keep class org.android.spdy.
{;}
-keep class org.android.agoo.{;}
-dontwarn anet.
*
-dontwarn org.android.spdy.**
-dontwarn org.android.agoo.**

-keepclasseswithmembernames class com.xiaomi.*{;}
-keep public class * extends com.xiaomi.mipush.sdk.PushMessageReceiver

-dontwarn com.xiaomi.push.service.b

-keep class org.apache.http.**
-keep interface org.apache.http.**
-dontwarn org.apache.**

okhttp3.x

-dontwarn com.squareup.okhttp3.**
-keep class com.squareup.okhttp3.** { ;}
-dontwarn okio.
*

sharesdk

-keep class cn.sharesdk.{;}
-keep class com.sina.
{;}
-keep class .R$ {;}
-keep class *.R{;}

-keep class com.mob.{;}
-dontwarn com.mob.
*
-dontwarn cn.sharesdk.**
-dontwarn *.R$

nineoldandroids-2.4.0.jar

-keep public class com.nineoldandroids.** {*;}

####################zxing#####################
-keep class com.google.zxing.** {;}
-dontwarn com.google.zxing.
*

百度定位

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

okhttp

-dontwarn com.squareup.okhttp.**
-keep class com.squareup.okhttp.{*;}

retrofit

-dontwarn retrofit.**
-keep class retrofit.** { ; }
-keepattributes Signature
-keepattributes Exceptions
-dontwarn okio.
*

recyclerview-animators

-keep class jp.wasabeef.** {;}
-dontwarn jp.wasabeef.

multistateview

-keep class com.kennyc.view.** { ; }
-dontwarn com.kennyc.view.

universal-image-loader 混淆

-dontwarn com.nostra13.universalimageloader.**
-keep class com.nostra13.universalimageloader.** { *; }

ormlite

-keep class com.j256.**
-keepclassmembers class com.j256.** { ; }
-keep enum com.j256.
*
-keepclassmembers enum com.j256.** { ; }
-keep interface com.j256.
*
-keepclassmembers interface com.j256.** { *; }

umeng

========= 友盟 =================

-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{;}
下面中括號(hào)的地方需要要填你的包名
-keep public class [your_pkg].R$
{
public static final int *;
}
-keepclassmembers class * {
public <init> (org.json.JSONObject);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

友盟自動(dòng)更新

-keep public class com.umeng.fb.ui.ThreadView {
}
-keep public class * extends com.umeng.**

以下包不進(jìn)行過濾

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

-ButterKnife 7.0

-keep class butterknife.** { ; }
-dontwarn butterknife.internal.
*
-keep class *$$ViewBinder { ; }
-keepclasseswithmembernames class * {
@butterknife.
<fields>;
}
-keepclasseswithmembernames class * {
@butterknife.
<methods>;
}

AndFix

-keep class * extends java.lang.annotation.Annotation
-keepclasseswithmembernames class * {
native <methods>;
}

eventbus 3.0

-keepattributes Annotation
-keepclassmembers class ** {
@org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
<init>(java.lang.Throwable);
}

EventBus

-keepclassmembers class ** {
public void onEvent();
}
-keepclassmembers class ** {
public void xxxxxx(
*);
}

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

-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 public class * implements java.io.Serializable {*;}

support-v4

https://stackoverflow.com/questions/18978706/obfuscate-android-support-v7-widget-gridlayout-issue

-dontwarn android.support.v4.**
-keep class android.support.v4.app.** { ; }
-keep interface android.support.v4.app.
* { ; }
-keep class android.support.v4.
* { *; }

support-v7

-dontwarn android.support.v7.**
-keep class android.support.v7.internal.** { ; }
-keep interface android.support.v7.internal.
* { ; }
-keep class android.support.v7.
* { *; }

support design

@link http://stackoverflow.com/a/31028536

-dontwarn android.support.design.**
-keep class android.support.design.** { ; }
-keep interface android.support.design.
* { ; }
-keep public class android.support.design.R$
{ *; }

-------------------------------------------------------------------------

picasso

-keep class com.squareup.picasso.** {; }
-dontwarn com.squareup.picasso.
*

glide

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
**[] $VALUES;
public *;
}

# ######## greenDao混淆

# -------------------------------------------

-keep class de.greenrobot.dao.** {*;}
-keepclassmembers class * extends de.greenrobot.dao.AbstractDao {
public static Java.lang.String TABLENAME;
}
-keep class **$Properties

# ############### volley混淆

# -------------------------------------------

-keep class com.android.volley.** {;}
-keep class com.android.volley.toolbox.
* {;}
-keep class com.android.volley.Response$
{ ; }
-keep class com.android.volley.Request$
{ ; }
-keep class com.android.volley.RequestQueue$
{ ; }
-keep class com.android.volley.toolbox.HurlStack$
{ ; }
-keep class com.android.volley.toolbox.ImageLoader$
{ *; }

jpush極光推送

-dontwarn cn.jpush.**
-keep class cn.jpush.** { *; }

activeandroid

-keep class com.activeandroid.** { ; }
-dontwarn com.ikoding.app.biz.dataobject.
*
-keep public class com.ikoding.app.biz.dataobject.** { *;}
-keepattributes Annotation

log4j

-dontwarn org.apache.log4j.**
-keep class org.apache.log4j.** { *;}

下面幾行 是環(huán)信即時(shí)通信的代碼混淆

-keep class com.easemob.** {;}
-keep class org.jivesoftware.
* {;}
-dontwarn com.easemob.
*

融云

-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}

-keepattributes Exceptions,InnerClasses

-keep class io.rong.** {*;}

-keep class * implements io.rong.imlib.model.MessageContent{*;}

-keepattributes Signature

-keepattributes Annotation

-keep class sun.misc.Unsafe { *; }

-keep class com.google.gson.examples.android.model.** { *; }

-keepclassmembers class * extends com.sea_monster.dao.AbstractDao {
public static java.lang.String TABLENAME;
}
-keep class $Properties
-dontwarn org.eclipse.jdt.annotation.

-keep class com.ultrapower.** {*;}

高徳地圖

-dontwarn com.amap.api.**
-dontwarn com.a.a.**
-dontwarn com.autonavi.**
-keep class com.amap.api.** {;}
-keep class com.autonavi.
* {;}
-keep class com.a.a.
* {*;}

---------------------------------反射相關(guān)的類和方法-----------------------

在這下面寫反射相關(guān)的類和方法,沒有就不用寫唉擂!

---------------------------------與js互相調(diào)用的類------------------------

在這下面寫與js互相調(diào)用的類睁本,沒有就去掉這句話!

---------------------------------自定義View的類------------------------

在這下面寫自定義View的類的類啡莉,沒有就去掉這句話港准!

SuperID

郭宇翔貢獻(xiàn)混淆代碼

作者Github地址:https://github.com/yourtion

-keep class .R$ {;}
-keep class com.isnc.facesdk.aty.{;}
-keep class com.isnc.facesdk.
{;}
-keep class com.isnc.facesdk.common.{;}
-keep class com.isnc.facesdk.net.
{;}
-keep class com.isnc.facesdk.view.{;}
-keep class com.isnc.facesdk.viewmodel.
{;}
-keep class com.matrixcv.androidapi.face.*{;}

retrofit2.x

-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions

Rxjava RxAndroid

-dontwarn rx.*
-dontwarn sun.misc.**

-keepclassmembers class rx.internal.util.unsafe.ArrayQueueField* {
long producerIndex;
long consumerIndex;
}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
rx.internal.util.atomic.LinkedQueueNode producerNode;
}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
rx.internal.util.atomic.LinkedQueueNode consumerNode;
}

litepal

-dontwarn org.litepal.
-keep class org.litepal.* { ; }
-keep enum org.litepal.*
-keep interface org.litepal. { ; }
-keep public class extends org.litepal.
-keepattributes Annotation
-keepclassmembers class extends org.litepal.crud.DataSupport{;}

fastJson

-dontwarn com.alibaba.fastjson.**
-keep class com.alibaba.fastjson.** { *; }

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市票罐,隨后出現(xiàn)的幾起案子叉趣,更是在濱河造成了極大的恐慌,老刑警劉巖该押,帶你破解...
    沈念sama閱讀 221,406評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件疗杉,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡蚕礼,警方通過查閱死者的電腦和手機(jī)烟具,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,395評(píng)論 3 398
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來奠蹬,“玉大人朝聋,你說我怎么就攤上這事《谠辏” “怎么了冀痕?”我有些...
    開封第一講書人閱讀 167,815評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)狸演。 經(jīng)常有香客問我言蛇,道長(zhǎng),這世上最難降的妖魔是什么宵距? 我笑而不...
    開封第一講書人閱讀 59,537評(píng)論 1 296
  • 正文 為了忘掉前任腊尚,我火速辦了婚禮,結(jié)果婚禮上满哪,老公的妹妹穿的比我還像新娘婿斥。我一直安慰自己,他們只是感情好哨鸭,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,536評(píng)論 6 397
  • 文/花漫 我一把揭開白布民宿。 她就那樣靜靜地躺著,像睡著了一般像鸡。 火紅的嫁衣襯著肌膚如雪勘高。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,184評(píng)論 1 308
  • 那天,我揣著相機(jī)與錄音华望,去河邊找鬼蕊蝗。 笑死,一個(gè)胖子當(dāng)著我的面吹牛赖舟,可吹牛的內(nèi)容都是我干的财搁。 我是一名探鬼主播商架,決...
    沈念sama閱讀 40,776評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了担猛?” 一聲冷哼從身側(cè)響起遭赂,我...
    開封第一講書人閱讀 39,668評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤缀雳,失蹤者是張志新(化名)和其女友劉穎题诵,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體讲衫,經(jīng)...
    沈念sama閱讀 46,212評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡缕棵,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,299評(píng)論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了涉兽。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片招驴。...
    茶點(diǎn)故事閱讀 40,438評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖枷畏,靈堂內(nèi)的尸體忽然破棺而出别厘,到底是詐尸還是另有隱情,我是刑警寧澤拥诡,帶...
    沈念sama閱讀 36,128評(píng)論 5 349
  • 正文 年R本政府宣布触趴,位于F島的核電站,受9級(jí)特大地震影響渴肉,放射性物質(zhì)發(fā)生泄漏冗懦。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,807評(píng)論 3 333
  • 文/蒙蒙 一宾娜、第九天 我趴在偏房一處隱蔽的房頂上張望批狐。 院中可真熱鬧扇售,春花似錦前塔、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,279評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至困乒,卻和暖如春寂屏,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,395評(píng)論 1 272
  • 我被黑心中介騙來泰國(guó)打工迁霎, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留吱抚,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,827評(píng)論 3 376
  • 正文 我出身青樓考廉,卻偏偏與公主長(zhǎng)得像秘豹,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子昌粤,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,446評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容

  • 有的時(shí)候心中壓抑的想法既绕,一吐出來可能就發(fā)泄了,沒有經(jīng)過深刻的醞釀便沒有了形涮坐,所以思考不到時(shí)便不用急于表露凄贩,讓你的...
    呃稀稀di閱讀 249評(píng)論 0 0
  • 好朋友阿琳最近很不爽廓译,和領(lǐng)導(dǎo)關(guān)系緊張评肆,跟我說:“這老板太難伺候了,我真想辭職不干了非区,自己創(chuàng)業(yè)算了瓜挽!”阿琳不是第一個(gè)...
    職場(chǎng)木沐說閱讀 600評(píng)論 6 14