summaryrefslogtreecommitdiffstats
path: root/mobile/android/config/proguard/proguard.cfg
blob: f44730e72cbabec9f750b184082ff7ec2371ef84 (plain)
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# Dalvik renders preverification unuseful (Would just slightly bloat the file).
-dontpreverify

# Uncomment to have Proguard list dead code detected during the run - useful for cleaning up the codebase.
# -printusage

-dontskipnonpubliclibraryclassmembers
-verbose
-allowaccessmodification

# Preserve all fundamental application classes.
-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.app.backup.BackupAgentHelper
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.preference.Preference
-keep public class * extends org.mozilla.gecko.fxa.sync.FxAccountSyncAdapter
-keep class org.mozilla.gecko.fxa.sync.FxAccountSyncAdapter

-keep public class * extends android.support.v4.app.Fragment

# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

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


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

# Keep setters in support Fragment so that Robocop tests work,
# specifically testBrowserSearchVisibility.
-keepclassmembers public class * extends android.support.v4.app.Fragment {
   void set*(***);
   *** get*();
}

# Preserve enums. (For awful reasons, the runtime accesses them using introspection...)
-keepclassmembers enum * {
     *;
}

#
# Rules from ProGuard's Android example:
# http://proguard.sourceforge.net/manual/examples.html#androidapplication
#

# Keep a fixed source file attribute and all line number tables to get line
# numbers in the stack traces.
# You can comment this out if you're not interested in stack traces.

-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

# RemoteViews might need annotations.

-keepattributes *Annotation*

# Preserve all View implementations, their special context constructors, and
# their setters.

-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*(...);
}

# Preserve all classes that have special context constructors, and the
# constructors themselves.

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

# Preserve the special fields of all Parcelable implementations.

-keepclassmembers class * implements android.os.Parcelable {
    static android.os.Parcelable$Creator CREATOR;
}

# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.

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

# Preserve the required interface from the License Verification Library
# (but don't nag the developer if the library is not used at all).

-keep public interface com.android.vending.licensing.ILicensingService

-dontnote com.android.vending.licensing.ILicensingService

# The Android Compatibility library references some classes that may not be
# present in all versions of the API, but we know that's ok.

-dontwarn android.support.**

# Preserve all native method names and the names of their classes.

-keepclasseswithmembernames class * {
    native <methods>;
}

#
# Mozilla-specific rules
#
# Merging classes can generate dex warnings about anonymous inner classes.
-optimizations !class/merging/horizontal
-optimizations !class/merging/vertical

# This optimisation causes corrupt bytecode if we run more than two passes.
# Testing shows that running the extra passes of everything else saves us
# more than this optimisation does, so bye bye!
-optimizations !code/allocation/variable

# Keep miscellaneous targets.

# Keep Robocop targets. TODO: Can omit these from release builds. Also, Bug 916507.

# Same formula as above...
-keep @interface org.mozilla.gecko.annotation.RobocopTarget
-keep @org.mozilla.gecko.annotation.RobocopTarget class *
-keepclassmembers class * {
    @org.mozilla.gecko.annotation.RobocopTarget *;
}
-keepclassmembers @org.mozilla.gecko.annotation.RobocopTarget class * {
    *;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.annotation.RobocopTarget <methods>;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.annotation.RobocopTarget <fields>;
}

-keep class **.R$*

# Keep all interfaces that might be dynamically required by Java Addons.
-keep class org.mozilla.javaaddons.* {
    *;
}

-keep class org.mozilla.javaaddons.*$* {
    *;
}

# Disable obfuscation because it makes exception stack traces more difficult to read.
-dontobfuscate

# Suppress warnings about missing descriptor classes.
#-dontnote **,!ch.boye.**,!org.mozilla.gecko.sync.**

-include "play-services-keeps.cfg"

# Don't print spurious warnings from the support library.
# See: http://stackoverflow.com/questions/22441366/note-android-support-v4-text-icucompatics-cant-find-dynamically-referenced-cl
-dontnote android.support.**

-include "adjust-keeps.cfg"

-include "leakcanary-keeps.cfg"

-include "appcompat-v7-keeps.cfg"

-include "proguard-android.cfg"

-include "../../geckoview/proguard-rules.txt"