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