blob: 7e7b2701cae1659c87a8901eb0df09a659ecec8b [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 Dukedd1fd792022-10-13 16:30:47 -07005# Preserve line number information for debugging stack traces.
6-keepattributes SourceFile,LineNumberTable
7
Jared Duke3837a942022-07-25 16:49:39 -07008# 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
Ying Wang57453512013-05-17 10:02:00 -070013# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
14-keepclassmembers enum * {
15 public static **[] values();
16 public static ** valueOf(java.lang.String);
17}
18
19# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
Jared Dukedf60c0b2022-02-07 10:29:28 -080020-keepclasseswithmembernames,includedescriptorclasses class * {
Ying Wang57453512013-05-17 10:02:00 -070021 native <methods>;
22}
23
24# class$ methods are inserted by some compilers to implement .class construct,
25# see http://proguard.sourceforge.net/manual/examples.html#library
26-keepclassmembernames class * {
27 java.lang.Class class$(java.lang.String);
28 java.lang.Class class$(java.lang.String, boolean);
29}
30
Ying Wang57453512013-05-17 10:02:00 -070031# Keep serializable classes and necessary members for serializable classes
32# Copied from the ProGuard manual at http://proguard.sourceforge.net.
33-keepnames class * implements java.io.Serializable
34-keepclassmembers class * implements java.io.Serializable {
35 static final long serialVersionUID;
36 private static final java.io.ObjectStreamField[] serialPersistentFields;
37 !static !transient <fields>;
38 private void writeObject(java.io.ObjectOutputStream);
39 private void readObject(java.io.ObjectInputStream);
40 java.lang.Object writeReplace();
41 java.lang.Object readResolve();
42}
43
Ying Wang480a9bb2015-05-11 14:56:20 -070044# Keep Throwable's constructor that takes a String argument.
45-keepclassmembers class * extends java.lang.Throwable {
46 <init>(java.lang.String);
47}
48
Ying Wang57453512013-05-17 10:02:00 -070049# Please specify classes to be kept explicitly in your package's configuration.
50# -keep class * extends android.app.Activity
51# -keep class * extends android.view.View
52# -keep class * extends android.app.Service
53# -keep class * extends android.content.BroadcastReceiver
54# -keep class * extends android.content.ContentProvider
55# -keep class * extends android.preference.Preference
56# -keep class * extends android.app.BackupAgent
57
Scott Kennedy62eb51a2014-04-07 11:25:47 -070058# Parcelable CREATORs must be kept for Parcelable functionality
Jared Duke9d27a922022-09-19 16:23:16 -070059-keepclassmembers class * implements android.os.Parcelable {
Scott Kennedy62eb51a2014-04-07 11:25:47 -070060 public static final ** CREATOR;
61}
Ying Wang57453512013-05-17 10:02:00 -070062
63# The support library contains references to newer platform versions.
64# Don't warn about those in case this app is linking against an older
65# platform version. We know about them, and they are safe.
66# See proguard-android.txt in the SDK package.
Ying Wang4f5d0e62015-05-04 19:21:48 -070067#
68# DO NOT USE THIS: We figured it's dangerous to blindly ignore all support library warnings.
69# ProGuard may strip members of subclass of unknown super classes, in case an app is linking against
70# LOCAL_SDK_VERSION lower than the support library's LOCAL_SDK_VERSION.
71# See bug/20658265.
72# -dontwarn android.support.**
Ying Wangf864d502014-06-17 11:53:31 -070073
Colin Crosse75840f2019-04-11 14:09:37 -070074# From https://github.com/google/guava/wiki/UsingProGuardWithGuava
75# Striped64, LittleEndianByteArray, UnsignedBytes, AbstractFuture
76-dontwarn sun.misc.Unsafe
77# Futures.getChecked (which often won't work with Proguard anyway) uses this. It
78# has a fallback, but again, don't use Futures.getChecked on Android regardless.
79-dontwarn java.lang.ClassValue
80
Jared Duke3ca564b2022-08-10 15:14:06 -070081# Ignore missing annotation references for various support libraries.
82# While this is not ideal, it should be relatively safe given that
83# 1) runtime-visible annotations will still be kept, and 2) compile-time
84# annotations are stripped by R8 anyway.
85# Note: The ** prefix is used to accommodate jarjar repackaging.
86# TODO(b/242088131): Remove these exemptions after resolving transitive libs
87# dependencies that are provided to R8.
88-dontwarn **android**.annotation*.**
89-dontwarn **com.google.errorprone.annotations.**
90-dontwarn javax.annotation.**
91-dontwarn org.checkerframework.**
92-dontwarn org.jetbrains.annotations.**
93
Ying Wangf864d502014-06-17 11:53:31 -070094# Less spammy.
95-dontnote
Colin Cross7a9acce2019-08-26 14:22:02 -070096
97# The lite proto runtime uses reflection to access fields based on the names in
zhidou12fdb342022-07-12 21:20:03 +000098# the schema, keep all the fields. Wildcard is used to apply the rule to classes
99# that have been renamed with jarjar.
100-keepclassmembers class * extends **.protobuf.MessageLite { <fields>; }