1 # Modified from https://robotsandpencils.com/blog/use-proguard-android-library/.
3 # Preserve all annotations.
5 -keepattributes *Annotation*
7 # Preserve all .class method names.
9 -keepclassmembernames class * {
10 java.lang.Class class$(java.lang.String);
11 java.lang.Class class$(java.lang.String, boolean);
14 # Preserve all native method names and the names of their classes.
16 -keepclasseswithmembernames,includedescriptorclasses class * {
20 # Preserve the special static methods that are required in all enumeration
23 -keepclassmembers class * extends java.lang.Enum {
24 public static **[] values();
25 public static ** valueOf(java.lang.String);
28 # Explicitly preserve all serialization members. The Serializable interface
29 # is only a marker interface, so it wouldn't save them.
30 # You can comment this out if your library doesn't use serialization.
31 # If your code contains serializable classes that have to be backward
32 # compatible, please refer to the manual.
34 -keepclassmembers class * implements java.io.Serializable {
35 static final long serialVersionUID;
36 static final java.io.ObjectStreamField[] serialPersistentFields;
37 private void writeObject(java.io.ObjectOutputStream);
38 private void readObject(java.io.ObjectInputStream);
39 java.lang.Object writeReplace();
40 java.lang.Object readResolve();
43 # Preserve all View implementations and their special context constructors.
45 -keep public class * extends android.view.View {
46 public <init>(android.content.Context);
47 public <init>(android.content.Context, android.util.AttributeSet);
48 public <init>(android.content.Context, android.util.AttributeSet, int);
49 public void set*(...);
52 # Keep setters in Views so that animations can still work.
53 # See http://proguard.sourceforge.net/manual/examples.html#beans
54 # From tools/proguard/proguard-android.txt.
55 -keepclassmembers public class * extends android.view.View {
60 # Preserve all classes that have special context constructors, and the
61 # constructors themselves.
63 -keepclasseswithmembers class * {
64 public <init>(android.content.Context, android.util.AttributeSet);
67 # Preserve the special fields of all Parcelable implementations.
69 -keepclassmembers class * implements android.os.Parcelable {
70 static android.os.Parcelable$Creator CREATOR;
73 # Preserve static fields of inner classes of R classes that might be accessed
74 # through introspection.
76 -keepclassmembers class **.R$* {
77 public static <fields>;
80 # GeckoView specific rules.
82 # Keep everthing in org.mozilla.geckoview
83 -keep class org.mozilla.geckoview.** { *; }
85 -keep class org.mozilla.gecko.SysInfo {
89 -keep class org.mozilla.gecko.mozglue.JNIObject {
93 -keep class * extends org.mozilla.gecko.mozglue.JNIObject {
97 # Keep the annotation.
98 -keep @interface org.mozilla.gecko.annotation.JNITarget
100 # Keep classes tagged with the annotation.
101 -keep @org.mozilla.gecko.annotation.JNITarget class *
103 # Keep all members of an annotated class.
104 -keepclassmembers @org.mozilla.gecko.annotation.JNITarget class * {
108 # Keep annotated members of any class.
109 -keepclassmembers class * {
110 @org.mozilla.gecko.annotation.JNITarget *;
113 # Keep classes which contain at least one annotated element. Split over two directives
114 # because, according to the developer of ProGuard, "the option -keepclasseswithmembers
115 # doesn't combine well with the '*' wildcard" (And, indeed, using it causes things to
116 # be deleted that we want to keep.)
117 -keepclasseswithmembers class * {
118 @org.mozilla.gecko.annotation.JNITarget <methods>;
120 -keepclasseswithmembers class * {
121 @org.mozilla.gecko.annotation.JNITarget <fields>;
124 # Keep WebRTC targets.
125 -keep @interface org.mozilla.gecko.annotation.WebRTCJNITarget
126 -keep @org.mozilla.gecko.annotation.WebRTCJNITarget class *
127 -keepclassmembers class * {
128 @org.mozilla.gecko.annotation.WebRTCJNITarget *;
130 -keepclassmembers @org.mozilla.gecko.annotation.WebRTCJNITarget class * {
133 -keepclasseswithmembers class * {
134 @org.mozilla.gecko.annotation.WebRTCJNITarget <methods>;
136 -keepclasseswithmembers class * {
137 @org.mozilla.gecko.annotation.WebRTCJNITarget <fields>;
140 # Keep generator-targeted entry points.
141 -keep @interface org.mozilla.gecko.annotation.WrapForJNI
142 -keep @org.mozilla.gecko.annotation.WrapForJNI class *
143 -keepclassmembers,includedescriptorclasses class * {
144 @org.mozilla.gecko.annotation.WrapForJNI *;
146 -keepclasseswithmembers,includedescriptorclasses class * {
147 @org.mozilla.gecko.annotation.WrapForJNI <methods>;
149 -keepclasseswithmembers,includedescriptorclasses class * {
150 @org.mozilla.gecko.annotation.WrapForJNI <fields>;
153 # Keep all members of an annotated class.
154 -keepclassmembers,includedescriptorclasses @org.mozilla.gecko.annotation.WrapForJNI class * {
158 # Keep Reflection targets.
159 -keep @interface org.mozilla.gecko.annotation.ReflectionTarget
160 -keep @org.mozilla.gecko.annotation.ReflectionTarget class *
161 -keepclassmembers class * {
162 @org.mozilla.gecko.annotation.ReflectionTarget *;
164 -keepclassmembers @org.mozilla.gecko.annotation.ReflectionTarget class * {
167 -keepclasseswithmembers class * {
168 @org.mozilla.gecko.annotation.ReflectionTarget <methods>;
170 -keepclasseswithmembers class * {
171 @org.mozilla.gecko.annotation.ReflectionTarget <fields>;
174 # Avoid "Warning: org.yaml.snakeyaml.scanner.ScannerImpl: can't find
175 # referenced method 'java.nio.ByteBuffer flip()' in library class
176 # java.nio.ByteBuffer".
177 # Between Java 1.8 and 1.9, the signature of `flip()` changed, which
180 -dontwarn org.yaml.snakeyaml.scanner.ScannerImpl