blob: f9d2d30d5575f48a9310009c5e47b5035765993d [file] [log] [blame]
Ying Wang38cdd442013-05-30 10:45:46 -07001# 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 Duke3837a942022-07-25 16:49:39 -07005# 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 Wang57453512013-05-17 10:02:00 -070010# 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 Dukedf60c0b2022-02-07 10:29:28 -080017-keepclasseswithmembernames,includedescriptorclasses class * {
Ying Wang57453512013-05-17 10:02:00 -070018 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 Wang57453512013-05-17 10:02:00 -070028# 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 Wang480a9bb2015-05-11 14:56:20 -070041# Keep Throwable's constructor that takes a String argument.
42-keepclassmembers class * extends java.lang.Throwable {
43 <init>(java.lang.String);
44}
45
Ying Wang57453512013-05-17 10:02:00 -070046# 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 Kennedy62eb51a2014-04-07 11:25:47 -070055# Parcelable CREATORs must be kept for Parcelable functionality
Jared Duke9d27a922022-09-19 16:23:16 -070056-keepclassmembers class * implements android.os.Parcelable {
Scott Kennedy62eb51a2014-04-07 11:25:47 -070057 public static final ** CREATOR;
58}
Ying Wang57453512013-05-17 10:02:00 -070059
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 Wang4f5d0e62015-05-04 19:21:48 -070064#
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 Wangf864d502014-06-17 11:53:31 -070070
Colin Crosse75840f2019-04-11 14:09:37 -070071# 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 Duke3ca564b2022-08-10 15:14:06 -070078# 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 Wangf864d502014-06-17 11:53:31 -070091# Less spammy.
92-dontnote
Colin Cross7a9acce2019-08-26 14:22:02 -070093
94# The lite proto runtime uses reflection to access fields based on the names in
zhidou12fdb342022-07-12 21:20:03 +000095# 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>; }