blob: 53f63d8ea047fc43f8472964b81c26ee0d0d8e93 [file] [log] [blame]
Ying Wang7311a342013-08-21 18:32:49 -07001# We have moved -dontobfuscate and -dontoptimize to the makefiles.
Ying Wang3b2bdf12010-02-01 09:51:23 -08002# dex does not like code run through proguard optimize and preverify steps.
Ying Wang7311a342013-08-21 18:32:49 -07003# -dontoptimize
Ying Wang3b2bdf12010-02-01 09:51:23 -08004-dontpreverify
5
6# Don't obfuscate. We only need dead code striping.
Ying Wang7311a342013-08-21 18:32:49 -07007# -dontobfuscate
Ying Wang3b2bdf12010-02-01 09:51:23 -08008
9# Add this flag in your package's own configuration if it's needed.
10#-flattenpackagehierarchy
11
Jared Duke97a99032022-08-02 16:05:03 -070012# Keep classes and methods that have @VisibleForTesting annotations, except in
13# intermediate libraries that export those annotations (e.g., androidx, guava).
14# This avoids keeping library-specific test code that isn't actually needed
15# for platform testing.
16# TODO(b/239961360): Migrate away from androidx.annotation.VisibleForTesting
17# and com.google.common.annotations.VisibleForTesting use in platform code.
18-keep @**.VisibleForTesting class !androidx.**,!com.google.common.**,*
19-keepclassmembers class !androidx.**,!com.google.common.**,* {
20 @**.VisibleForTesting *;
Ying Wang38cdd442013-05-30 10:45:46 -070021}
Ying Wang3b2bdf12010-02-01 09:51:23 -080022
Jared Duke7d0c90b2022-05-09 18:09:01 -070023# Keep rule for members that are needed solely to keep alive downstream weak
24# references, and could otherwise be removed after tree shaking optimizations.
25-keepclassmembers,allowaccessmodification,allowobfuscation,allowshrinking class * {
26 @com.android.internal.annotations.KeepForWeakReference <fields>;
27}
28
Jared Duke4bd749b2021-12-14 15:28:33 -080029# Understand the common @Keep annotation from various Android packages:
30# * android.support.annotation
31# * androidx.annotation
32# * com.android.internal.annotations
33-keep class **android**.annotation*.Keep
Colin Cross38b48de2019-03-26 09:48:28 -070034
Jared Duke4bd749b2021-12-14 15:28:33 -080035-keep @**android**.annotation*.Keep class * { *; }
Colin Cross38b48de2019-03-26 09:48:28 -070036
37-keepclasseswithmembers class * {
Jared Duke4bd749b2021-12-14 15:28:33 -080038 @**android**.annotation*.Keep <methods>;
Colin Cross38b48de2019-03-26 09:48:28 -070039}
40
41-keepclasseswithmembers class * {
Jared Duke4bd749b2021-12-14 15:28:33 -080042 @**android**.annotation*.Keep <fields>;
Colin Cross38b48de2019-03-26 09:48:28 -070043}
44
45-keepclasseswithmembers class * {
Jared Duke4bd749b2021-12-14 15:28:33 -080046 @**android**.annotation*.Keep <init>(...);
Colin Cross38b48de2019-03-26 09:48:28 -070047}
48
Ying Wang57453512013-05-17 10:02:00 -070049-include proguard_basic_keeps.flags