1# Some classes in the libraries extend package private classes to chare common functionality
2# that isn't explicitly part of the API
3-dontskipnonpubliclibraryclasses -dontskipnonpubliclibraryclassmembers
4
5# Preserve line number information for debugging stack traces.
6-keepattributes SourceFile,LineNumberTable
7
8# Annotations are implemented as attributes, so we have to explicitly keep them.
9# Keep all runtime-visible annotations like RuntimeVisibleParameterAnnotations
10# and RuntimeVisibleTypeAnnotations, as well as associated defaults.
11-keepattributes RuntimeVisible*Annotation*,AnnotationDefault
12
13# With R8 full mode, certain attributes are only kept when matched with an
14# explicit keep rule for that target, even with a global -keepattributes rule.
15# As such, we can add the global keep rule here with minimal cost while
16# simplifying incremental development.
17-keepattributes Exceptions
18
19# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
20-keepclassmembers enum * {
21    public static **[] values();
22    public static ** valueOf(java.lang.String);
23}
24
25# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
26-keepclasseswithmembernames,includedescriptorclasses class * {
27    native <methods>;
28}
29
30# class$ methods are inserted by some compilers to implement .class construct,
31# see http://proguard.sourceforge.net/manual/examples.html#library
32-keepclassmembernames class * {
33    java.lang.Class class$(java.lang.String);
34    java.lang.Class class$(java.lang.String, boolean);
35}
36
37# Keep serializable classes and necessary members for serializable classes
38# Copied from the ProGuard manual at http://proguard.sourceforge.net.
39-keepnames class * implements java.io.Serializable
40-keepclassmembers class * implements java.io.Serializable {
41    static final long serialVersionUID;
42    private static final java.io.ObjectStreamField[] serialPersistentFields;
43    !static !transient <fields>;
44    private void writeObject(java.io.ObjectOutputStream);
45    private void readObject(java.io.ObjectInputStream);
46    java.lang.Object writeReplace();
47    java.lang.Object readResolve();
48}
49
50# Keep all Javascript API methods
51-keepclassmembers class * {
52    @android.webkit.JavascriptInterface <methods>;
53}
54
55# Keep Throwable's constructor that takes a String argument.
56-keepclassmembers class * extends java.lang.Throwable {
57  <init>(java.lang.String);
58}
59
60# Please specify classes to be kept explicitly in your package's configuration.
61# -keep class * extends android.app.Activity
62# -keep class * extends android.view.View
63# -keep class * extends android.app.Service
64# -keep class * extends android.content.BroadcastReceiver
65# -keep class * extends android.content.ContentProvider
66# -keep class * extends android.preference.Preference
67# -keep class * extends android.app.BackupAgent
68
69# Parcelable CREATORs must be kept for Parcelable functionality
70-keepclassmembers class * implements android.os.Parcelable {
71  public static final ** CREATOR;
72}
73
74# The support library contains references to newer platform versions.
75# Don't warn about those in case this app is linking against an older
76# platform version.  We know about them, and they are safe.
77# See proguard-android.txt in the SDK package.
78#
79# DO NOT USE THIS: We figured it's dangerous to blindly ignore all support library warnings.
80# ProGuard may strip members of subclass of unknown super classes, in case an app is linking against
81# LOCAL_SDK_VERSION lower than the support library's LOCAL_SDK_VERSION.
82# See bug/20658265.
83# -dontwarn android.support.**
84
85# From https://github.com/google/guava/wiki/UsingProGuardWithGuava
86# Striped64, LittleEndianByteArray, UnsignedBytes, AbstractFuture
87-dontwarn sun.misc.Unsafe
88# Futures.getChecked (which often won't work with Proguard anyway) uses this. It
89# has a fallback, but again, don't use Futures.getChecked on Android regardless.
90-dontwarn java.lang.ClassValue
91
92# Ignore missing annotation references for various support libraries.
93# While this is not ideal, it should be relatively safe given that
94# 1) runtime-visible annotations will still be kept, and 2) compile-time
95# annotations are stripped by R8 anyway.
96# Note: The ** prefix is used to accommodate jarjar repackaging.
97# TODO(b/242088131): Remove these exemptions after resolving transitive libs
98# dependencies that are provided to R8.
99-dontwarn **android**.annotation*.**
100-dontwarn **com.google.errorprone.annotations.**
101-dontwarn javax.annotation.**
102-dontwarn org.checkerframework.**
103-dontwarn org.jetbrains.annotations.**
104
105# Less spammy.
106-dontnote
107
108# The lite proto runtime uses reflection to access fields based on the names in
109# the schema, keep all the fields. Wildcard is used to apply the rule to classes
110# that have been renamed with jarjar.
111-keepclassmembers class * extends **.protobuf.MessageLite { <fields>; }
112