blob: 5b88cd93ef9c368e55fe91f707f30f8ce342ce81 [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
Jared Dukecc28b022023-03-28 14:09:31 -070044# Keep all Javascript API methods
45-keepclassmembers class * {
46 @android.webkit.JavascriptInterface <methods>;
47}
48
Ying Wang480a9bb2015-05-11 14:56:20 -070049# Keep Throwable's constructor that takes a String argument.
50-keepclassmembers class * extends java.lang.Throwable {
51 <init>(java.lang.String);
52}
53
Ying Wang57453512013-05-17 10:02:00 -070054# Please specify classes to be kept explicitly in your package's configuration.
55# -keep class * extends android.app.Activity
56# -keep class * extends android.view.View
57# -keep class * extends android.app.Service
58# -keep class * extends android.content.BroadcastReceiver
59# -keep class * extends android.content.ContentProvider
60# -keep class * extends android.preference.Preference
61# -keep class * extends android.app.BackupAgent
62
Scott Kennedy62eb51a2014-04-07 11:25:47 -070063# Parcelable CREATORs must be kept for Parcelable functionality
Jared Duke9d27a922022-09-19 16:23:16 -070064-keepclassmembers class * implements android.os.Parcelable {
Scott Kennedy62eb51a2014-04-07 11:25:47 -070065 public static final ** CREATOR;
66}
Ying Wang57453512013-05-17 10:02:00 -070067
68# The support library contains references to newer platform versions.
69# Don't warn about those in case this app is linking against an older
70# platform version. We know about them, and they are safe.
71# See proguard-android.txt in the SDK package.
Ying Wang4f5d0e62015-05-04 19:21:48 -070072#
73# DO NOT USE THIS: We figured it's dangerous to blindly ignore all support library warnings.
74# ProGuard may strip members of subclass of unknown super classes, in case an app is linking against
75# LOCAL_SDK_VERSION lower than the support library's LOCAL_SDK_VERSION.
76# See bug/20658265.
77# -dontwarn android.support.**
Ying Wangf864d502014-06-17 11:53:31 -070078
Colin Crosse75840f2019-04-11 14:09:37 -070079# From https://github.com/google/guava/wiki/UsingProGuardWithGuava
80# Striped64, LittleEndianByteArray, UnsignedBytes, AbstractFuture
81-dontwarn sun.misc.Unsafe
82# Futures.getChecked (which often won't work with Proguard anyway) uses this. It
83# has a fallback, but again, don't use Futures.getChecked on Android regardless.
84-dontwarn java.lang.ClassValue
85
Jared Duke3ca564b2022-08-10 15:14:06 -070086# Ignore missing annotation references for various support libraries.
87# While this is not ideal, it should be relatively safe given that
88# 1) runtime-visible annotations will still be kept, and 2) compile-time
89# annotations are stripped by R8 anyway.
90# Note: The ** prefix is used to accommodate jarjar repackaging.
Sam Delmerico59570d12023-01-06 10:23:44 -050091# TODO(b/266561579): Remove this exemptions after resolving jarjar-ed transitive libs
Jared Duke3ca564b2022-08-10 15:14:06 -070092-dontwarn **android**.annotation*.**
Sam Delmerico59570d12023-01-06 10:23:44 -050093
94# These classes generate warnings of the kind `Library class extends program class`
95# because some apps have deps that statically include the same libraries as the app,
96# and r8 complains that a library is implementing a class provided by the app (the "program").
97-dontwarn com.google.protobuf.**
98-dontwarn kotlin.reflect.jvm.internal.ReflectionFactoryImpl
Jared Duke3ca564b2022-08-10 15:14:06 -070099
Ying Wangf864d502014-06-17 11:53:31 -0700100# Less spammy.
101-dontnote
Colin Cross7a9acce2019-08-26 14:22:02 -0700102
103# The lite proto runtime uses reflection to access fields based on the names in
zhidou12fdb342022-07-12 21:20:03 +0000104# the schema, keep all the fields. Wildcard is used to apply the rule to classes
105# that have been renamed with jarjar.
106-keepclassmembers class * extends **.protobuf.MessageLite { <fields>; }