gradle的配置
proguard-rules.pro混淆配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
###-----------基本配置-不能被混淆的------------
-keep
public
class
*
extends
android.app.Activity
-keep
public
class
*
extends
android.app.Fragment
-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
#support.v4/v7包不混淆
-keep
class
android.support.** { *; }
-keep
class
android.support.v4.** { *; }
-keep
public
class
*
extends
android.support.v4.**
-keep
interface
android.support.v4.app.** { *; }
-keep
class
android.support.v7.** { *; }
-keep
public
class
*
extends
android.support.v7.**
-keep
interface
android.support.v7.app.** { *; }
-dontwarn android.support.** # 忽略警告
#保持注解继承类不混淆
-keep
class
*
extends
java.lang.annotation.Annotation {*;}
#保持Serializable实现类不被混淆
-keepnames
class
*
implements
java.io.Serializable
#保持Serializable不被混淆并且
enum
类也不被混淆
-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();
}
#保持枚举
enum
类不被混淆
-keepclassmembers
enum
* {
public
static
**[] values();
public
static
** valueOf(java.lang.String);
}
#自定义组件不被混淆
-keep
public
class
*
extends
android.view.View {
public
<init>(android.content.Context);
public
<init>(android.content.Context, android.util.AttributeSet);
public
<init>(android.content.Context, android.util.AttributeSet,
int
);
public
void
set*(...);
}
#不混淆资源类
-keepclassmembers
class
**.R$* {
public
static
<fields>;
}
###-----------第三方jar包library混淆配置------------
#ormlite混淆配置
#-libraryjars libs/ormlite-android-
5.0
.jar
#-libraryjars libs/ormlite-core-
5.0
.jar
-dontwarn com.j256.ormlite.**
-keep
class
com.j256.ormlite.** { *;}
-keep
class
com.envy15.cherry.base.orm.** { *;}
#json-lib混淆配置
#-libraryjars libs/json-lib-
2.4
-jdk15.jar
-dontwarn net.sf.json.**
-keep
class
net.sf.json.** { *;}
#json-lib关联包
#-libraryjars libs/commons-beanutils-
1.8
.
3
.jar
-dontwarn org.apache.commons.**
-keep
class
org.apache.commons.** { *;}
#universalimageloader图片加载框架不混淆
-keep
class
com.nostra13.universalimageloader.** { *; }
-dontwarn com.nostra13.universalimageloader.**
#Gson相关的不混淆配置
-keepattributes Signature
-keepattributes *Annotation*
-keep
class
com.google.gson.** { *; }
-dontwarn com.google.gson.**
-keep
class
com.envy15.cherry.fragment.crossover.model.** { *; }
-dontwarn com.envy15.cherry.fragment.crossover.model.**
-keep
class
com.envy15.cherry.fragment.discover.model.** { *; }
-dontwarn com.envy15.cherry.fragment.discover.model.**
-keep
class
com.envy15.cherry.fragment.local.model.** { *; }
-dontwarn com.envy15.cherry.fragment.local.model.**
-keep
class
com.envy15.cherry.fragment.setting.model.** { *; }
-dontwarn com.envy15.cherry.fragment.setting.model.**
#prt-lib下拉刷新框架不混淆
-keep
class
in.srain.cube.views.ptr.** { *; }
-dontwarn in.srain.cube.views.ptr.**
#PullToRefreshLibrary下拉刷新框架不混淆
-keep
class
com.handmark.pulltorefresh.library.** { *; }
-dontwarn com.handmark.pulltorefresh.library.**
#参考:
# http:
//blog.csdn.net/zuiwuyuan/article/details/48552701
# http:
//blog.csdn.net/fengyuzhengfan/article/details/43876197
# http:
//blog.isming.me/2014/05/31/use-proguard/
# http:
//hanhailong.com/2015/12/28/Android%E8%BF%9B%E9%98%B6%E4%B9%8BProGuard%E4%BB%A3%E7%A0%81%E6%B7%B7%E6%B7%86/
# 关于混淆的思考:
# https:
//www.zhihu.com/question/37446729
# 扩展:资源文件混淆
# http:
//blog.csdn.net/Fancy_xty/article/details/51202866
#代码混淆规则
# 指定代码的压缩级别
#-optimizationpasses
5
# 是否使用大小写混合
#-dontusemixedcaseclassnames
# 是否混淆第三方jar
#-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
方法不被混淆
#
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
* { # 保持枚举
enum
类不被混淆
#
public
static
**[] values();
#
public
static
** valueOf(java.lang.String);
#}
#
#-keep
class
*
implements
android.os.Parcelable { # 保持 Parcelable 不被混淆
#
public
static
final
android.os.Parcelable$Creator *;
#}
#-keep
class
MyClass; # 保持自己定义的类不被混淆
|
打包发布
1
2
3
4
|
* 崩溃日志记录
* 参考:
* http:
//blog.csdn.net/u012333411/article/details/49019415
* http:
//blog.csdn.net/wangyuexing_blog/article/details/39009069
|