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